:root {
  --green: #07c160;
  --green-dark: #06a050;
  --bg: #f2f4f7;
  --card: #ffffff;
  --ink: #1f2329;
  --ink2: #6b7280;
  --line: #e5e8ee;
  --amber: #b45309;
  --amber-bg: #fef3c7;
  --red: #dc2626;
  --red-bg: #fee2e2;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .06);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, "PingFang SC", "Helvetica Neue", sans-serif;
  background: var(--bg); color: var(--ink); height: 100vh; overflow: hidden;
}

/* 顶栏 */
.topbar {
  height: 60px; background: var(--card); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 36px; height: 36px; border-radius: 10px; color: #fff; font-weight: 700;
  background: linear-gradient(135deg, var(--green), #0ea968);
  display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.title { font-size: 16px; font-weight: 600; }
.subtitle { font-size: 12px; color: var(--ink2); }
.job-status { display: flex; align-items: center; gap: 10px; }
.job-id { font-size: 12px; color: var(--ink2); font-family: ui-monospace, monospace; }
.pill {
  font-size: 12px; padding: 4px 12px; border-radius: 999px;
  background: #eef0f4; color: var(--ink2);
}
.pill.running { background: #e0f2fe; color: #0369a1; }
.pill.done { background: #dcfce7; color: #15803d; }
.pill.error { background: var(--red-bg); color: var(--red); }

/* 布局 */
.layout {
  display: grid; grid-template-columns: 400px 1fr; gap: 18px;
  height: calc(100vh - 60px); padding: 18px 24px;
}
.steps { overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }

/* 卡片 */
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px;
}
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.step-num {
  width: 24px; height: 24px; border-radius: 8px; background: #eef0f4;
  font-size: 13px; font-weight: 700; display: flex; align-items: center;
  justify-content: center; color: var(--ink2);
}
.card.ready .step-num { background: var(--green); color: #fff; }
.card-title { font-size: 15px; font-weight: 600; flex: 1; }
.card-state { font-size: 12px; color: var(--green-dark); font-weight: 500; }
.hint { font-size: 12px; color: var(--ink2); margin-bottom: 10px; line-height: 1.6; }

/* 按钮 */
.btn {
  border: 1px solid var(--line); background: #fff; border-radius: 9px;
  padding: 8px 14px; font-size: 13px; cursor: pointer; color: var(--ink);
  transition: all .15s; text-decoration: none; display: inline-block; text-align: center;
}
.btn:hover { border-color: var(--green); color: var(--green-dark); }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.primary:hover { background: var(--green-dark); }
.btn.block { width: 100%; margin-top: 10px; }
.btn.run {
  background: var(--ink); color: #fff; border: none; font-size: 15px;
  padding: 12px; border-radius: 10px; font-weight: 600;
}
.btn.run:disabled { background: #c9ced6; cursor: not-allowed; }
.btn.run:not(:disabled):hover { background: #000; }
.btn.accent { background: #fff7ed; border-color: #fdba74; color: #c2410c; }
.btn-row { display: flex; gap: 8px; margin-top: 10px; }
.btn-row .btn { flex: 1; }

/* 模板输入 */
.tpl-textarea {
  width: 100%; height: 90px; margin-top: 10px; border: 1px solid var(--line);
  border-radius: 9px; padding: 10px; font-size: 12px; resize: vertical;
  font-family: ui-monospace, monospace; color: var(--ink2);
}
.tpl-textarea:focus { outline: 2px solid var(--green); border-color: transparent; }

/*  chips  */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip {
  font-size: 12px; background: #f0fbf4; color: var(--green-dark);
  border: 1px solid #bbe7cc; padding: 3px 10px; border-radius: 999px;
}

/* 拖放区 */
.dropzone {
  border: 1.5px dashed #c9ced6; border-radius: 10px; padding: 18px;
  text-align: center; font-size: 13px; color: var(--ink2); cursor: pointer;
  transition: all .15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--green); background: #f0fbf4; }
.dz-icon { font-size: 22px; margin-bottom: 4px; color: var(--green); }
.file-list { list-style: none; margin-top: 8px; max-height: 110px; overflow-y: auto; }
.file-list li {
  font-size: 12px; padding: 4px 8px; color: var(--ink2);
  display: flex; justify-content: space-between;
}
.file-list li .ok { color: var(--green-dark); }

/* 阶段 */
.stages { list-style: none; margin-top: 12px; }
.stages li {
  font-size: 13px; padding: 6px 0 6px 26px; position: relative; color: var(--ink2);
}
.stages li::before {
  content: ""; position: absolute; left: 4px; top: 10px;
  width: 10px; height: 10px; border-radius: 50%; background: #d4d9e0;
}
.stages li.running { color: var(--ink); }
.stages li.running::before { background: #0ea5e9; animation: pulse 1s infinite; }
.stages li.done { color: var(--ink); }
.stages li.done::before { background: var(--green); }
.stages li.error { color: var(--red); }
.stages li.error::before { background: var(--red); }
.stages li .detail { display: block; font-size: 11px; color: var(--ink2); margin-top: 2px; }
@keyframes pulse { 50% { opacity: .3; } }

/* 右侧主区 */
.main {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden;
}
.tabs { display: flex; border-bottom: 1px solid var(--line); padding: 0 12px; }
.tab {
  border: none; background: none; padding: 14px 18px; font-size: 14px;
  color: var(--ink2); cursor: pointer; border-bottom: 2px solid transparent;
}
.tab.active { color: var(--ink); font-weight: 600; border-bottom-color: var(--green); }
.pane { display: none; flex: 1; overflow: auto; }
.pane.active { display: flex; }
#pane-preview { background: #e9ecf1; justify-content: center; padding: 24px 0; }

/* 手机框 */
.phone {
  width: 414px; background: #fff; border-radius: 28px; position: relative;
  box-shadow: 0 12px 40px rgba(16, 24, 40, .18); overflow: hidden;
  border: 8px solid #111;
}
.phone-notch {
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 140px; height: 22px; background: #111; border-radius: 0 0 14px 14px;
  z-index: 2;
}
.phone iframe { width: 100%; height: 100%; border: none; min-height: 720px; }
.phone-empty {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px; color: #b6bcc8;
  font-size: 13px; background: #fff;
}
.empty-icon { font-size: 40px; }

/* 审计单 */
#pane-audit { flex-direction: column; padding: 18px 22px; gap: 12px; }
.notice {
  border-radius: 10px; padding: 12px 14px; font-size: 13px; line-height: 1.6;
}
.notice.warn { background: var(--amber-bg); color: var(--amber); }
.notice.overflow { background: #eff6ff; color: #1d4ed8; }
.audit-block { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.audit-block-head {
  background: #f8f9fb; padding: 8px 14px; font-size: 13px; font-weight: 600;
  display: flex; justify-content: space-between;
}
.audit-block-head .act { color: var(--ink2); font-weight: 400; }
.audit-row {
  padding: 8px 14px; font-size: 12px; border-top: 1px solid #f0f2f5;
  display: flex; gap: 8px; align-items: baseline; line-height: 1.6;
}
.audit-row .old { color: #b6bcc8; text-decoration: line-through; flex: 1; word-break: break-all; }
.audit-row .arrow { color: var(--ink2); }
.audit-row .new { color: var(--ink); flex: 1; word-break: break-all; }
.audit-row.gen { background: #fffbeb; }
.gen-tag {
  font-size: 10px; background: var(--amber-bg); color: var(--amber);
  border-radius: 4px; padding: 1px 6px; white-space: nowrap;
}
.gen-edit { display: flex; gap: 6px; flex: 1; }
.gen-edit input {
  flex: 1; border: 1px solid #fcd34d; border-radius: 6px; padding: 3px 8px;
  font-size: 12px;
}
.gen-edit button {
  border: none; background: var(--amber); color: #fff; border-radius: 6px;
  font-size: 11px; padding: 3px 10px; cursor: pointer;
}
.json-view {
  padding: 20px; font-size: 12px; font-family: ui-monospace, monospace;
  white-space: pre-wrap; word-break: break-all; color: var(--ink2);
}
