:root {
  --bg: #f5f6fa;
  --card: #ffffff;
  --line: #e5e7ef;
  --line-soft: #eef0f6;
  --text: #171a23;
  --muted: #6b7280;
  --accent: #4f46e5;
  --accent-2: #7c3aed;
  --accent-soft: #eef2ff;
  --ok: #047857;
  --ok-soft: #e7f7ef;
  --warn: #b45309;
  --warn-soft: #fff5e6;
  --err: #b91c1c;
  --err-soft: #fdecec;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(20, 24, 40, .04), 0 8px 24px rgba(20, 24, 40, .05);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --mono: "SFMono-Regular", "JetBrains Mono", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
p { margin: 0; }
code { font-family: var(--mono); font-size: .92em; background: var(--line-soft); padding: 1px 5px; border-radius: 5px; }

/* ---------------------------------------------------------------- topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(255, 255, 255, .86);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand strong { display: block; font-size: 15px; line-height: 1.2; }
.brand-sub { color: var(--muted); font-size: 12px; }
.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: -.02em;
  box-shadow: 0 6px 16px rgba(79, 70, 229, .3);
}
.brand-mark.small { width: 36px; height: 36px; font-size: 13px; border-radius: 11px; }
.top-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pill {
  font-size: 12px;
  color: var(--muted);
  background: var(--line-soft);
  border-radius: 999px;
  padding: 4px 10px;
  white-space: nowrap;
}
.pill-ok { color: var(--ok); background: var(--ok-soft); }

/* ---------------------------------------------------------------- layout */
.page { max-width: 1240px; margin: 0 auto; padding: 32px 24px 64px; }
.hero { margin-bottom: 26px; }
.hero h1 { font-size: 28px; line-height: 1.25; margin-bottom: 8px; }
.hero p { color: var(--muted); max-width: 780px; }

.layout { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(280px, .9fr); gap: 20px; align-items: start; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
form#job-form { padding: 8px 24px 24px; }

/* ---------------------------------------------------------------- steps */
.step { padding: 22px 0; border-bottom: 1px dashed var(--line); }
.step:last-of-type { border-bottom: 0; }
.step-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 14px; }
.step-no {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: 13px;
  display: grid;
  place-items: center;
  margin-top: 2px;
}
.step-head h2 { font-size: 16px; }
.step-head p { color: var(--muted); font-size: 13px; margin-top: 2px; }
.optional {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  background: var(--line-soft);
  border-radius: 6px;
  padding: 1px 6px;
  vertical-align: middle;
  margin-left: 4px;
}

/* ---------------------------------------------------------------- inputs */
input[type=url], input[type=text], input[type=password], textarea, select {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: #fbfbfe;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 11px 13px;
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
input:focus, textarea:focus, select:focus {
  background: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .12);
}
textarea { resize: vertical; min-height: 110px; line-height: 1.6; }
.field-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.hint { color: var(--muted); font-size: 12.5px; margin-top: 7px; }
.form-status.ok { color: var(--ok); }
.form-status.err { color: var(--err); }
.muted { color: var(--muted); }

.cred-panel {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfbfe;
}
.cred-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 10px;
}
.cred-note { font-weight: 400; font-size: 12px; color: var(--muted); }
.cred-ok { color: var(--ok); }
.cred-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.secret-row { display: flex; gap: 6px; align-items: stretch; }
.secret-row input { flex: 1; min-width: 0; }
button.small { padding: 6px 10px; font-size: 12.5px; }
.cred-actions { display: flex; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- dropzone */
.dropzone {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border: 1.5px dashed #cfd4e2;
  border-radius: 13px;
  background: #fbfbfe;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  flex-wrap: wrap;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone input[type=file] { display: none; }
.dz-icon { font-size: 22px; }
.dz-copy { display: flex; flex-direction: column; line-height: 1.35; }
.dz-copy strong { font-size: 14px; }
.dz-copy em { font-style: normal; color: var(--muted); font-size: 12.5px; }
.dz-list { flex-basis: 100%; display: none; flex-direction: column; gap: 4px; padding-top: 8px; border-top: 1px dashed var(--line); }
.dz-list.show { display: flex; }
.dz-file { display: flex; justify-content: space-between; gap: 12px; font-size: 12.5px; color: var(--muted); }
.dz-file b { font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------------------------------------------------------- buttons */
button, .button-link {
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  border-radius: 10px;
  padding: 10px 18px;
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform .05s, background .15s, box-shadow .15s;
  white-space: nowrap;
}
button:active { transform: translateY(1px); }
.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 8px 20px rgba(79, 70, 229, .28);
  min-width: 150px;
}
.primary:disabled { opacity: .6; cursor: wait; box-shadow: none; }
.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
}
.ghost:hover { background: var(--line-soft); color: var(--text); }
.button-link { background: var(--accent); color: #fff; padding: 8px 14px; font-size: 13px; }
.button-link.secondary { background: #fff; color: var(--accent); border-color: var(--line); }
.icon-btn { background: transparent; border: 0; font-size: 16px; color: var(--muted); padding: 6px 8px; }
.icon-btn:hover { color: var(--text); background: var(--line-soft); }

.submit-row { display: flex; align-items: center; gap: 14px; padding-top: 22px; flex-wrap: wrap; }
.form-status { color: var(--muted); font-size: 13px; }

/* ---------------------------------------------------------------- side */
.side { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 84px; }
.side-card { padding: 20px; }
.side-card h3 { font-size: 14px; margin-bottom: 12px; }
.flow { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 11px; }
.flow li { display: flex; gap: 10px; font-size: 13px; color: #374151; align-items: baseline; }
.flow span {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 5px;
  padding: 1px 5px;
  flex: 0 0 auto;
}
.tips { margin: 0; padding-left: 18px; color: var(--muted); font-size: 12.8px; display: flex; flex-direction: column; gap: 8px; }

/* ---------------------------------------------------------------- jobs */
.jobs-card { margin-top: 20px; padding: 20px 24px 12px; }
.jobs-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.jobs-head h2 { font-size: 16px; }
.jobs { display: flex; flex-direction: column; }
.job {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--line-soft);
  flex-wrap: wrap;
}
.job:last-child { border-bottom: 0; }
.job-main { flex: 1 1 320px; min-width: 0; }
.job-title { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-meta { color: var(--muted); font-size: 12px; margin-top: 2px; display: flex; gap: 8px; flex-wrap: wrap; }
.job-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.job-actions a, .job-actions button { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; font-weight: 500; }
.job-actions button { background: #fff; border: 1px solid var(--line); color: var(--muted); }
.job-actions button:hover { color: var(--text); background: var(--line-soft); }
.job-actions .dl { background: var(--accent-soft); color: var(--accent); border: 1px solid transparent; }
.job-actions .danger:hover { color: var(--err); border-color: #f3c6c6; background: var(--err-soft); }

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 999px;
  padding: 4px 10px;
  white-space: nowrap;
}
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-queued { color: #6b7280; background: #f1f2f7; }
.status-preparing, .status-converting, .status-compiling, .status-packaging { color: var(--accent); background: var(--accent-soft); }
.status-preparing::before, .status-converting::before, .status-compiling::before, .status-packaging::before { animation: pulse 1.1s infinite; }
.status-done { color: var(--ok); background: var(--ok-soft); }
.status-failed { color: var(--err); background: var(--err-soft); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }

.empty { color: var(--muted); font-size: 13px; padding: 26px 4px; text-align: center; }

/* ---------------------------------------------------------------- drawer */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 20, 30, .34);
  z-index: 40;
  backdrop-filter: blur(2px);
}
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(680px, 94vw);
  background: #10131c;
  color: #d7dbe7;
  z-index: 50;
  display: flex;
  flex-direction: column;
  box-shadow: -20px 0 50px rgba(0, 0, 0, .28);
  transform: translateX(0);
  transition: transform .22s ease;
}
.drawer.hidden, .drawer-overlay.hidden { display: none; }
.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.drawer-head h3 { font-size: 15px; color: #fff; }
.drawer-head .icon-btn { color: #9aa3b8; }
.drawer-head .icon-btn:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.drawer-actions { display: flex; align-items: center; gap: 8px; padding: 12px 20px; flex-wrap: wrap; }
.drawer-error { color: #fca5a5; font-size: 12.5px; }
.log {
  flex: 1;
  overflow: auto;
  margin: 0;
  padding: 16px 20px 28px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  color: #c4cadb;
  background: #0b0e15;
}
.hidden { display: none !important; }

/* ---------------------------------------------------------------- toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: #171a23;
  color: #fff;
  padding: 11px 18px;
  border-radius: 11px;
  font-size: 13.5px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .25);
  z-index: 60;
  max-width: min(560px, 90vw);
}
.toast.error { background: #7f1d1d; }

/* ---------------------------------------------------------------- login */
.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 500px at 12% -10%, #e6e9ff 0%, transparent 60%),
    radial-gradient(700px 500px at 104% 8%, #f3e8ff 0%, transparent 55%),
    var(--bg);
}
.login-card {
  width: min(400px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 34px 30px 24px;
  box-shadow: 0 20px 60px rgba(24, 28, 48, .10);
  text-align: center;
}
.login-card .brand-mark { margin: 0 auto 16px; }
.login-card h1 { font-size: 21px; }
.login-card > .muted { margin-top: 6px; font-size: 13px; }
.login-form { text-align: left; margin-top: 24px; display: flex; flex-direction: column; gap: 8px; }
.login-form label { font-size: 13px; font-weight: 600; }
.login-form button { margin-top: 8px; width: 100%; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; padding: 11px; }
.alert { margin-top: 18px; background: var(--err-soft); color: var(--err); border-radius: 10px; padding: 9px 12px; font-size: 13px; text-align: left; }
.footnote { margin-top: 22px; color: #9ca3af; font-size: 11.5px; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1000px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: static; order: 2; }
  .hero h1 { font-size: 23px; }
  .page { padding: 24px 16px 48px; }
  .topbar-inner { padding: 10px 16px; }
  .top-actions .pill { display: none; }
}
@media (max-width: 620px) {
  .job { align-items: flex-start; }
  .job-actions { width: 100%; }
  form#job-form { padding: 4px 16px 18px; }
  .jobs-card { padding: 16px; }
  .drawer-actions .button-link { flex: 1; }
  .cred-grid { grid-template-columns: 1fr; }
}
