:root {
  --bg: #f6f6f4;
  --panel: #ffffff;
  --ink: #16161a;
  --ink-2: #4a4a55;
  --muted: #8a8a96;
  --line: #e7e6e2;
  --line-2: #d9d8d3;
  --accent: #3370ff;
  --accent-ink: #ffffff;
  --accent-soft: #eef3ff;
  --ok: #12a150;
  --ok-soft: #e7f6ee;
  --warn: #b7791f;
  --warn-soft: #fdf4e3;
  --bad: #d93a3a;
  --bad-soft: #fdecec;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(22, 22, 26, .04), 0 8px 24px rgba(22, 22, 26, .06);
  --font: "Inter", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 14px/1.6 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
code, .mono { font-family: var(--mono); font-size: .9em; }

/* ── buttons ─────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px;
  border-radius: 999px; border: 1px solid var(--line-2); background: var(--panel); cursor: pointer; font-weight: 500;
  transition: background .15s, border-color .15s, transform .05s; white-space: nowrap; }
.btn:hover { background: #f1f0ec; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn-primary:hover { background: #2b2b33; }
.btn-accent { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-accent:hover { background: #2a61e6; }
.btn-danger { color: var(--bad); }
.btn-sm { height: 30px; padding: 0 12px; font-size: 13px; }
.btn-block { width: 100%; height: 46px; font-size: 15px; }
.btn-ghost { border-color: transparent; background: transparent; }

/* ── fields ──────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.field .hint { font-size: 12px; color: var(--muted); }
.input, select.input, textarea.input { height: 42px; padding: 0 14px; border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  background: #fff; outline: none; transition: border-color .15s, box-shadow .15s; width: 100%; }
textarea.input { height: auto; min-height: 90px; padding: 10px 14px; resize: vertical; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.otp { letter-spacing: .5em; text-align: center; font-family: var(--mono); font-size: 20px; height: 52px; }

.alert { padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px; line-height: 1.55; }
.alert-bad { background: var(--bad-soft); color: #9b2323; }
.alert-ok { background: var(--ok-soft); color: #0c6b37; }
.alert-warn { background: var(--warn-soft); color: #7a5114; }
.alert-info { background: var(--accent-soft); color: #1f4fcc; }

.pill { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 500; background: #f0efeb; color: var(--ink-2); white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-bad { background: var(--bad-soft); color: var(--bad); }
.pill-accent { background: var(--accent-soft); color: var(--accent); }
.pill-plain::before { display: none; }

/* ── login ───────────────────────────────── */
.auth { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.auth-visual { position: relative; overflow: hidden; background: #0f0f13; color: #fff; padding: 40px 48px; display: flex; flex-direction: column; }
.auth-visual::before { content: ""; position: absolute; inset: -20%; background:
  radial-gradient(40% 35% at 20% 25%, rgba(51, 112, 255, .45), transparent 70%),
  radial-gradient(35% 30% at 80% 70%, rgba(255, 138, 76, .35), transparent 70%),
  radial-gradient(30% 30% at 60% 20%, rgba(46, 196, 182, .25), transparent 70%); filter: blur(10px); }
.auth-visual > * { position: relative; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; letter-spacing: .01em; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, #3370ff, #7a5cff 55%, #ff8a4c); display: grid; place-items: center; }
.brand-mark svg { width: 18px; height: 18px; }
.auth-visual h1 { font-size: clamp(30px, 3.2vw, 44px); line-height: 1.18; font-weight: 700; margin: auto 0 14px; padding-top: 24px; letter-spacing: -.01em; max-width: 14em; }
.auth-visual p.lede { color: rgba(255, 255, 255, .72); font-size: 15px; max-width: 30em; margin: 0 0 34px; }
.showcase { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 520px; margin-bottom: 30px; }
.shot { aspect-ratio: 3 / 4; border-radius: 12px; background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .1); padding: 10px; display: flex; flex-direction: column; justify-content: space-between; backdrop-filter: blur(6px); }
.shot .tag { align-self: flex-start; font-size: 11px; padding: 2px 8px; border-radius: 999px; background: rgba(255, 255, 255, .12); color: rgba(255, 255, 255, .85); }
.shot .obj { flex: 1; margin: 10px 8px; border-radius: 10px; }
.shot:nth-child(1) .obj { background: linear-gradient(160deg, #d9dde6, #9aa3b5); }
.shot:nth-child(2) .obj { background: linear-gradient(160deg, #ffd8bf, #ff8a4c); }
.shot:nth-child(3) .obj { background: linear-gradient(160deg, #c7f0ea, #2ec4b6); }
.shot .cap { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .25); width: 70%; }
.flow { display: flex; gap: 18px; flex-wrap: wrap; color: rgba(255, 255, 255, .7); font-size: 13px; }
.flow span { display: inline-flex; align-items: center; gap: 8px; }
.flow b { width: 20px; height: 20px; border-radius: 50%; background: rgba(255, 255, 255, .14); display: grid; place-items: center; font-size: 11px; font-weight: 600; color: #fff; }

.auth-form { display: flex; align-items: center; justify-content: center; padding: 40px 24px; background: var(--panel); }
.auth-card { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 18px; }
.auth-card h2 { font-size: 26px; margin: 0; font-weight: 700; letter-spacing: -.01em; }
.auth-card .sub { margin: -10px 0 4px; color: var(--muted); }
.feishu-ico { width: 20px; height: 20px; border-radius: 5px; background: #3370ff; display: grid; place-items: center; color: #fff; font-size: 11px; font-weight: 700; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 10px; align-items: center; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.small { font-size: 12px; color: var(--muted); }
.qr { align-self: center; width: 188px; height: 188px; border: 1px solid var(--line); border-radius: 12px; padding: 8px; background: #fff; }
.secret { font-family: var(--mono); font-size: 12px; background: #f4f3ef; border-radius: 6px; padding: 6px 10px; word-break: break-all; text-align: center; }
.steps-list { margin: 0; padding-left: 18px; color: var(--ink-2); font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
.auth-foot { margin-top: 8px; color: var(--muted); font-size: 12px; text-align: center; }

@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-visual { padding: 28px 20px 30px; }
  .auth-visual h1 { margin-top: 36px; font-size: 28px; }
  .showcase { display: none; }
  .auth-form { padding: 32px 16px 48px; }
}

/* ── console ─────────────────────────────── */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; }
.side .brand { padding: 4px 8px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 11px; color: var(--muted); letter-spacing: .08em; padding: 12px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--ink-2); font-weight: 500; }
.nav a:hover { background: #f3f2ee; text-decoration: none; }
.nav a.active { background: var(--ink); color: #fff; }
.nav svg { width: 16px; height: 16px; flex: none; }
.side-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 12px; display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: #e9e8e3; display: grid; place-items: center; font-weight: 600; font-size: 13px; overflow: hidden; flex: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.who { min-width: 0; flex: 1; }
.who b { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who span { font-size: 12px; color: var(--muted); }

.main { padding: 28px 32px 60px; max-width: 1180px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 24px; letter-spacing: -.01em; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.card h3 { margin: 0 0 4px; font-size: 15px; }
.card .desc { color: var(--muted); margin: 0 0 16px; font-size: 13px; }
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.stat { display: flex; flex-direction: column; gap: 8px; }
.stat .k { color: var(--muted); font-size: 13px; }
.stat .v { font-size: 22px; font-weight: 700; }
.checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.checklist li { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.checklist li:first-child { border-top: 0; }
.checklist .dot { width: 22px; height: 22px; border-radius: 50%; flex: none; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: #efeee9; color: var(--muted); }
.checklist .done .dot { background: var(--ok); color: #fff; }
.checklist .t { flex: 1; }
.checklist .t b { display: block; font-weight: 600; }
.checklist .t span { color: var(--muted); font-size: 13px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; font-weight: 500; color: var(--muted); background: #fbfbfa; }
tr:last-child td { border-bottom: 0; }
.user-cell { display: flex; align-items: center; gap: 10px; }
.actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.copy { display: flex; gap: 8px; }
.copy .input { font-family: var(--mono); font-size: 12px; background: #fafaf8; }
.switch { position: relative; width: 38px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #d6d5d0; border-radius: 999px; cursor: pointer; transition: .2s; }
.switch span::before { content: ""; position: absolute; width: 18px; height: 18px; left: 2px; top: 2px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::before { transform: translateX(16px); }

.provider { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 12px; background: #fff; }
.job { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.job:first-child { border-top: 0; }
.empty { color: var(--muted); text-align: center; padding: 28px 0; }

.toast { position: fixed; right: 20px; bottom: 20px; z-index: 50; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); font-size: 13px; opacity: 0; transform: translateY(8px); transition: .2s; pointer-events: none; max-width: 420px; }
.toast.show { opacity: 1; transform: none; }
.modal-bg { position: fixed; inset: 0; background: rgba(15, 15, 19, .45); display: grid; place-items: center; z-index: 40; padding: 16px; }
.modal { background: #fff; border-radius: 16px; padding: 22px; width: 100%; max-width: 440px; display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow); }
.modal h3 { margin: 0; }

.topbar { display: none; }
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .main { min-width: 0; }
  .side { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 30; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: var(--shadow); }
  .topbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
  .main { padding: 20px 16px 48px; }
  .form-grid { grid-template-columns: 1fr; }
}

.check { width: 16px; height: 16px; accent-color: var(--accent); }
.provider.is-off { background: #fbfbfa; }
.provider.is-off .form-grid, .provider.is-off .model-grid { opacity: .55; }
.model-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.model-chip { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px 0 10px; border: 1px solid var(--line-2); border-radius: 999px; cursor: pointer; font-size: 12.5px; background: #fff; user-select: none; }
.model-chip input { width: 14px; height: 14px; accent-color: var(--accent); margin: 0; }
.model-chip.on { border-color: var(--accent); background: var(--accent-soft); color: #1f4fcc; }
.model-chip .ord { width: 18px; height: 18px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.cap-select { height: 20px; padding: 0 4px; border: 0; border-radius: 6px; font-size: 11px; font-weight: 600; cursor: pointer; }
.cap-image { background: #eef3ff; color: #1f4fcc; }
.cap-text { background: #fff4e0; color: #9a5b00; }
.cap-video { background: #f1ebff; color: #5b34c7; }
.activity { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.activity:last-child { border-bottom: 0; }
.activity .when { flex: 0 0 132px; color: var(--muted); font-size: 12px; }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.kv > div { background: #f7f7f5; border-radius: 10px; padding: 10px 12px; }
.kv b { display: block; font-size: 18px; }
.kv span { font-size: 12px; color: var(--muted); }
pre.preview { white-space: pre-wrap; background: #f7f7f5; border-radius: 10px; padding: 12px; font-size: 12px; max-height: 320px; overflow: auto; margin: 0; }
.progress { height: 6px; border-radius: 3px; background: #efeee9; overflow: hidden; margin-top: 6px; }
.progress > i { display: block; height: 100%; background: var(--accent); transition: width .3s; }

/* 当前轮换顺序：拖动排序 + 移除 */
.chain-chip { cursor: grab; user-select: none; position: relative; padding-right: 4px; }
.chain-chip:active { cursor: grabbing; }
.chain-chip.dragging { opacity: .4; }
.chain-chip.drop-before { box-shadow: -3px 0 0 var(--accent); }
.chain-chip.drop-after { box-shadow: 3px 0 0 var(--accent); }
.chain-del { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; margin-left: 2px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: inherit; font-size: 13px; line-height: 1; cursor: pointer; opacity: .55; }
.chain-del:hover, .chain-del:focus-visible { opacity: 1; background: var(--bad-soft); color: var(--bad); outline: none; }

/* 图片输出：预估大小 */
.output-est { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; border-radius: 10px; background: var(--accent-soft); }
.output-est .est-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.output-est .est-size { font-size: 20px; color: var(--accent); }

/* 1688 找货源：选中商品一行（价格 · 标题 · 链接） */
.pick { display: flex; align-items: center; gap: 8px; margin-top: 4px; font-size: 12px; min-width: 0; }
.pick-price { flex: none; font-weight: 600; color: var(--ink); }
.pick-title { flex: 1; min-width: 0; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pick a { flex: none; }

/* 1688 找货源：运行看板（两步进度 + 耗时 / 用量） */
.src-sec { font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.src-sec .small { font-weight: 400; margin-left: 6px; }
.src-flow { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.src-step { position: relative; display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 10px; background: #f7f7f5; border-top: 3px solid var(--line-2); min-width: 0; }
.src-step .k { font-size: 12px; color: var(--ink-2); font-weight: 500; }
.src-step b { font-size: 22px; line-height: 1.25; }
.src-step.is-accent { border-top-color: var(--accent); }
.src-step.is-ok { border-top-color: var(--ok); }
.src-step.is-bad { border-top-color: var(--bad); background: var(--bad-soft); }
.src-step.is-bad b { color: var(--bad); }
.src-mini { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 16px; }
.src-why { color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
@media (max-width: 860px) { .src-flow { grid-template-columns: repeat(2, minmax(0, 1fr)); } .src-mini { grid-template-columns: 1fr; } }

/* ── 灵犀AI 授权 ─────────────────────────── */
.lx-stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.lx-stats .src-step { cursor: pointer; border: 0; border-top: 3px solid var(--line-2); text-align: left; font: inherit; }
.lx-stats .src-step.is-on { box-shadow: inset 0 0 0 1.5px var(--ink); }
.lx-stats .src-step.is-warn { border-top-color: var(--warn); }
.lx-code { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.lx-acts { display: flex; gap: 6px; flex-wrap: wrap; }
.modal.is-wide { max-width: 820px; max-height: 90vh; overflow: auto; }
.lx-kv { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 16px; }
.lx-kv div { display: flex; flex-direction: column; min-width: 0; }
.lx-kv span { font-size: 12px; color: var(--muted); }
.lx-kv b { font-weight: 500; overflow-wrap: anywhere; }
@media (max-width: 860px) { .lx-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } .lx-kv { grid-template-columns: 1fr 1fr; } }

/* 灵犀AI Key 池 */
.lx-keys td { vertical-align: top; }
.lx-keys tr.dragging { opacity: .45; }
.lx-grip { cursor: grab; color: var(--muted, #999); user-select: none; letter-spacing: -2px; }
.lx-bar { height: 4px; border-radius: 2px; background: var(--line); margin-top: 4px; overflow: hidden; }
.lx-bar > i { display: block; height: 100%; border-radius: 2px; }
