:root {
  --bg: #f5f1e8;
  --paper: #fffdf8;
  --ink: #1f2a30;
  --muted: #5f6b73;
  --line: #d8d0c2;
  --accent: #a54b2a;
  --accent-soft: #f3e2d8;
  --olive: #556b2f;
  --olive-soft: #eef2e5;
  --warn-soft: #fcf6ef;
  --warn-line: #eadcca;
  --radius: 18px;
  --radius-sm: 14px;
  --shadow: 0 12px 40px rgba(71, 56, 35, 0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background:
    radial-gradient(circle at top left, rgba(165, 75, 42, 0.12), transparent 30%),
    linear-gradient(180deg, #f8f3ea 0%, var(--bg) 100%);
  color: var(--ink);
  font-family: "PingFang SC", "Hiragino Sans GB", "Noto Serif SC", serif;
  line-height: 1.75;
  min-height: 100vh;
}

.wrap {
  width: min(980px, calc(100% - 32px));
  margin: 0 auto;
  padding: 40px 0 56px;
}

/* ---- 通用面板 ---- */
.hero,
.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero { padding: 34px 30px 28px; }
.panel { margin-top: 22px; padding: 24px 22px; }

h1, h2, h3 {
  font-weight: 700;
  line-height: 1.3;
}

h1 {
  font-size: clamp(28px, 5vw, 44px);
  margin-bottom: 14px;
}

h2 {
  font-size: 24px;
  margin-bottom: 14px;
}

h3 {
  font-size: 18px;
  margin: 16px 0 8px;
}

p { margin: 0 0 12px; }

.muted { color: var(--muted); }

.eyebrow {
  display: inline-block;
  margin-bottom: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  letter-spacing: 0.08em;
}

.tag {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--olive-soft);
  color: var(--olive);
  font-size: 13px;
  margin-right: 6px;
}

/* ---- 统计卡片网格 ---- */
.grid {
  display: grid;
  gap: 18px;
  margin-top: 22px;
}

.summary {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stat {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fffaf2;
  font-size: 14px;
}

.stat b {
  display: block;
  font-size: 22px;
  color: var(--accent);
  margin-top: 4px;
}

/* ---- 鉴权行 ---- */
.auth-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0 0;
}

.auth-row label {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  color: var(--muted);
}

.auth-row input {
  flex: 1;
  max-width: 320px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  background: #fffaf2;
  color: var(--ink);
  transition: border-color 0.2s;
}

.auth-row input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(165, 75, 42, 0.1);
}

.btn-sm-auth {
  padding: 8px 14px;
  font-size: 14px;
  font-family: inherit;
  font-weight: 600;
  margin-top: 0;
  white-space: nowrap;
  border: 1px solid transparent;
  line-height: 1.75;
}

.auth-status {
  font-size: 12px;
  margin-left: 4px;
}

.auth-status.ok { color: var(--olive); }
.auth-status.fail { color: var(--accent); }

/* ---- 表单 ---- */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 18px;
  margin-bottom: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
}

.form-group.full-width {
  grid-column: 1 / -1;
}

.form-group label {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--ink);
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"] {
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 15px;
  font-family: inherit;
  background: #fffaf2;
  color: var(--ink);
  transition: border-color 0.2s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(165, 75, 42, 0.1);
}

.form-group input[type="file"] {
  display: none;
}

.upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: #fffaf2;
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
  justify-content: center;
}

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

.upload-btn.has-file {
  border-style: solid;
  border-color: var(--olive);
  background: var(--olive-soft);
  color: var(--olive);
}

.upload-btn-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
}

.upload-btn-icon {
  font-size: 16px;
}

.file-hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
  display: block;
}

/* ---- 按钮 ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 28px;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  line-height: 1.4;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  width: 100%;
  font-size: 16px;
  padding: 14px 28px;
}

.btn-primary:hover { background: #8d3e20; }
.btn-primary:disabled { background: #b8a89a; cursor: not-allowed; }

.btn-secondary {
  background: var(--olive-soft);
  color: var(--olive);
}

.btn-secondary:hover { background: #dde6d1; }

.btn-download {
  background: var(--olive);
  color: #fff;
  padding: 12px 28px;
  font-size: 15px;
  margin-top: 12px;
  display: inline-flex;
}

.btn-download:hover { background: #475a28; }

/* ---- 步骤列表 ---- */
.step-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.step-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14px;
  border: 1px solid var(--line);
  background: #fffaf2;
  transition: all 0.2s;
}

.step-item.pending { color: var(--muted); }
.step-item.running {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  border-color: var(--accent);
}
.step-item.done {
  background: var(--olive-soft);
  color: var(--olive);
  border-color: transparent;
}
.step-item.error {
  background: #fef2f2;
  color: #dc2626;
  border-color: #fca5a5;
}

.step-icon { width: 22px; text-align: center; flex-shrink: 0; }
.step-name { flex: 1; }
.step-time { font-size: 12px; color: var(--muted); }

/* ---- 日志 ---- */
.log-box {
  background: var(--ink);
  color: #e2e8f0;
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  max-height: 200px;
  overflow-y: auto;
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 12px;
  line-height: 1.6;
}

.log-box .log-line { padding: 1px 0; }
.log-box .log-time { color: #8896a4; }

/* ---- 阶段分割线（类似原页面 .phase） ---- */
.phase {
  padding: 18px 0;
  border-top: 1px dashed var(--line);
}

.phase:first-of-type {
  border-top: 0;
  padding-top: 0;
}

/* ---- 历史任务表格 ---- */
#task-list { overflow-x: auto; }

.task-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.task-table th,
.task-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

.task-table th {
  color: var(--muted);
  font-weight: 600;
}

.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.status-created { background: var(--warn-soft); color: #92600a; }
.status-running { background: var(--accent-soft); color: var(--accent); }
.status-completed { background: var(--olive-soft); color: var(--olive); }
.status-failed { background: #fee2e2; color: #dc2626; }

.btn-sm {
  padding: 5px 12px;
  font-size: 12px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  transition: all 0.2s;
  text-decoration: none;
  display: inline-flex;
}

.btn-sm-danger {
  background: #fee2e2;
  color: #dc2626;
  margin-left: 8px;
}

.btn-sm-danger:hover { background: #fecaca; }

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 24px;
  font-size: 14px;
}

/* ---- 响应式 ---- */
@media (max-width: 820px) {
  .summary { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 560px) {
  .wrap {
    width: min(100%, calc(100% - 20px));
    padding-top: 24px;
  }
  .hero, .panel { border-radius: var(--radius-sm); }
  .summary { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}
