:root {
  --bg: #0f1115; --panel: #1a1d24; --panel2: #21252e; --border: #2c313c;
  --text: #e6e8ec; --muted: #8b93a1; --accent: #4f8cff; --accent2: #3a6fd8;
  --ok: #34d399; --bad: #f87171; --warn: #fbbf24;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
}
h1, h3 { margin: 0 0 8px; }
.muted { color: var(--muted); }
.err { color: var(--bad); margin: 4px 0; }

/* 登录 */
.login-body { display: flex; align-items: center; justify-content: center; height: 100vh; }
.login-card {
  background: var(--panel); padding: 32px; border-radius: 12px; width: 320px;
  display: flex; flex-direction: column; gap: 12px; border: 1px solid var(--border);
}
.login-card h1 { text-align: center; }
.login-card .sub { text-align: center; color: var(--muted); margin: 0 0 8px; }
.login-card input, .login-card button { padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border); }
.login-card input { background: var(--panel2); color: var(--text); }
.login-card button { background: var(--accent); color: #fff; border: none; cursor: pointer; font-weight: 600; }

/* 顶栏 */
.topbar { display: flex; align-items: center; gap: 20px; padding: 10px 20px;
  background: var(--panel); border-bottom: 1px solid var(--border); }
.brand { font-weight: 700; font-size: 16px; }
.module-nav { display: flex; gap: 6px; }
.module-nav button { background: transparent; border: 1px solid var(--border); color: var(--muted);
  padding: 6px 14px; border-radius: 18px; cursor: pointer; }
.module-nav button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.spacer { flex: 1; }
.logout { color: var(--muted); text-decoration: none; }
.logout:hover { color: var(--text); }

/* tabs */
.tabs { display: flex; gap: 4px; padding: 12px 20px 0; }
.tab { background: transparent; border: none; color: var(--muted); padding: 8px 16px;
  cursor: pointer; border-bottom: 2px solid transparent; font-size: 14px; }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

main { padding: 16px 20px 40px; }
.view { display: none; }
.view.active { display: block; }

.toolbar { display: flex; align-items: center; gap: 16px; margin-bottom: 12px; }
.summary { color: var(--muted); }
.summary b { color: var(--text); }
.summary .ok { color: var(--ok); } .summary .bad { color: var(--bad); } .summary .warn { color: var(--warn); }

.btn { background: var(--panel2); color: var(--text); border: 1px solid var(--border);
  padding: 7px 14px; border-radius: 8px; cursor: pointer; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.small { padding: 3px 10px; font-size: 12px; }
.btn.danger { color: var(--bad); }

/* 表格 */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; min-width: 1000px; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--panel); position: sticky; top: 0; font-weight: 600; }
tr:hover td { background: var(--panel2); }
/* 文本列压窄，给图片让出空间 */
td.prompt { width: 220px; max-width: 220px; font-size: 12px; line-height: 1.45; }
/* 文本超过图片高度就在框内滚动，不再撑高整行 */
td.prompt .scroll { max-height: 360px; overflow-y: auto; white-space: pre-wrap; word-break: break-word; }
td.prompt .scroll::-webkit-scrollbar { width: 6px; }
td.prompt .scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
td.meta { color: var(--muted); font-size: 11px; line-height: 1.4; width: 142px; word-break: break-word; }
/* 任务状态徽标 */
.stbadge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.st-ok { background: rgba(52,211,153,.15); color: var(--ok); }
.st-bad { background: rgba(248,113,113,.15); color: var(--bad); }
.st-warn { background: rgba(251,191,36,.15); color: var(--warn); }
.st-mute { background: var(--panel2); color: var(--muted); }
.st-run { background: rgba(79,140,255,.15); color: var(--accent); }
.outnote { padding: 16px 8px; }

/* CSAM 信息小块 */
.csam { display: flex; flex-direction: column; gap: 3px; margin: 6px 0; }
.cb { font-size: 10.5px; padding: 1px 6px; border-radius: 4px; background: var(--panel2);
  border: 1px solid var(--border); color: var(--muted); align-self: flex-start; line-height: 1.5; }
.cb-warn { color: var(--warn); border-color: var(--warn); }
.cb-bad { color: var(--bad); border-color: var(--bad); font-weight: 600; }
.cb b.rd { color: var(--bad); }
/* 实际处理节点 + 耗时 metrics */
.nodemet { display: flex; flex-direction: column; gap: 2px; margin: 5px 0; }
.nm-reg, .nm-met { font-size: 10.5px; line-height: 1.5; align-self: flex-start;
  padding: 1px 6px; border-radius: 4px; border: 1px solid var(--border); }
.nm-reg { color: var(--accent); border-color: var(--accent); }
.nm-met { color: var(--muted); background: var(--panel2); cursor: help; }
/* 图片放大：等比、不裁切 */
.thumb { width: 280px; height: auto; max-height: 360px; object-fit: contain; border-radius: 8px;
  background: var(--panel2); border: 1px solid var(--border); cursor: zoom-in; }
.tag { display: inline-block; padding: 1px 7px; border-radius: 5px; font-size: 11px;
  background: var(--panel2); border: 1px solid var(--border); margin-right: 4px; }
.tag.recon { color: var(--warn); border-color: var(--warn); }
.tag.real { color: var(--ok); border-color: var(--ok); }
.tag.same { color: var(--muted); }
.tag.preset { background: rgba(79,140,255,.18); color: var(--accent); border-color: var(--accent); font-weight: 600; }
.zh-cell { color: var(--muted); font-style: italic; }

/* 重生成：输出格蒙层 + 菊花 */
.btn.small.regen { margin-top: 6px; }
.outcell { position: relative; display: inline-block; line-height: 0; }
.outcell .overlay { position: absolute; inset: 0; background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center; border-radius: 8px; }
.outcell .overlay.err { background: rgba(120,0,0,.7); }
.outcell .ov-msg { color: #fff; font-size: 12px; padding: 8px; text-align: center; line-height: 1.4; }
.spinner { width: 34px; height: 34px; border: 3px solid rgba(255,255,255,.25);
  border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.regen-bar { margin-top: 4px; display: flex; gap: 8px; align-items: center; line-height: 1.4; }
.regen-badge { background: var(--ok); color: #06281d; padding: 1px 7px; border-radius: 5px; font-size: 11px; font-weight: 600; }
.regen-bar a { color: var(--accent); font-size: 12px; text-decoration: none; }

/* ===== Lab（重做） ===== */
.lab2 { display: grid; grid-template-columns: 420px 1fr; gap: 18px; align-items: start; max-width: 1400px; }
.lab-card { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; }
.lab-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.lab-card-head h3 { margin: 0; font-size: 15px; }
.endpoint-chip { font-size: 11px; color: var(--muted); background: var(--panel2);
  border: 1px solid var(--border); padding: 3px 10px; border-radius: 14px; }

.fld { margin-bottom: 10px; }
.fld-label { font-size: 12.5px; color: var(--muted); margin-bottom: 4px; display: flex; align-items: center; gap: 6px; }
.link-btn { margin-left: auto; background: none; border: none; color: var(--accent); cursor: pointer; font-size: 12px; padding: 0; }

.lab-card textarea, .url-input, .num-input,
.modal-card input, .modal-card textarea {
  width: 100%; padding: 10px 12px; border-radius: 9px; background: var(--panel2);
  color: var(--text); border: 1px solid var(--border); font-family: inherit; font-size: 13px; line-height: 1.5;
}
.lab-card textarea { resize: vertical; }
.lab-card textarea:focus, .url-input:focus, .num-input:focus { outline: none; border-color: var(--accent); }
.url-input { margin-top: 8px; }
.num-input { width: 130px; }
select.url-input { cursor: pointer; }
.lab-jump { margin-top: 6px; width: 100%; }

/* style chips */
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip { background: var(--panel2); border: 1px solid var(--border); color: var(--text);
  padding: 6px 13px; border-radius: 16px; cursor: pointer; font-size: 12.5px; transition: .12s; }
.chip:hover { border-color: var(--accent); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

/* 输入图 dropzone */
.dropzone { position: relative; border: 1.5px dashed var(--border); border-radius: 11px;
  min-height: 96px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; overflow: hidden; background: var(--panel2); transition: .12s; }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: #1d2330; }
.dz-hint { display: flex; flex-direction: column; align-items: center; gap: 5px; color: var(--muted); font-size: 12.5px; padding: 12px; text-align: center; }
.dz-ic { font-size: 20px; opacity: .6; }
.dz-preview { display: none; width: 100%; max-height: 180px; object-fit: contain; }

.adv { margin-bottom: 10px; border: 1px solid var(--border); border-radius: 9px; padding: 0 12px; }
.adv summary { cursor: pointer; padding: 8px 0; font-size: 12.5px; color: var(--muted); }
.adv[open] summary { border-bottom: 1px solid var(--border); margin-bottom: 10px; }
.adv .fld:last-child { margin-bottom: 10px; }

/* 生成按钮：移到右侧结果区上方居中 */
.result-gen { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-bottom: 14px; }
.result-gen .btn-gen { width: auto; min-width: 220px; }
.btn-gen { width: 100%; padding: 11px 28px; border: none; border-radius: 10px; background: var(--accent);
  color: #fff; font-size: 14px; font-weight: 600; cursor: pointer; transition: .12s; }
.btn-gen:hover { background: var(--accent2); }
.btn-gen:disabled { opacity: .6; cursor: default; }
.status-line { margin-top: 7px; font-size: 12px; color: var(--muted); text-align: center; min-height: 16px; }
.expand-note { margin-top: 5px; font-size: 11.5px; color: var(--muted); min-height: 14px; }
.expand-note.ok { color: var(--ok); }
.expand-note.warn { color: var(--warn); }
/* undress: mask 缩略图 + 参数行 */
.mask-thumb { position: relative; display: inline-block; margin-top: 6px; }
.mask-thumb .mask-lab { position: absolute; top: 4px; left: 4px; background: rgba(0,0,0,.6);
  color: #fff; font-size: 10px; padding: 1px 5px; border-radius: 4px; }
.thumb.mini { width: 120px; max-height: 160px; }
.param-row { display: flex; gap: 12px; }
.param-row label { flex: 1; font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.param-row select { width: 100%; }
/* undress mask 第一步：segment 按钮 + 叠加视图 */
.seg-btn { width: 100%; }
.mask-view { display: flex; gap: 10px; margin-top: 8px; align-items: flex-start; }
.mask-overlay { position: relative; flex: 1; border-radius: 9px; overflow: hidden; background: var(--panel2); }
.mask-overlay .mask-base { display: block; width: 100%; }
.mask-overlay .mask-seg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; opacity: .5; mix-blend-mode: normal; }
.mask-bin { position: relative; width: 110px; flex: none; }
.mask-bin img { width: 110px; border-radius: 9px; border: 1px solid var(--border); background: #000; }
.mask-manual { margin-top: 8px; }
.mask-manual.adv { margin-bottom: 0; }
/* 回到顶部浮动按钮 */
.back-top { position: fixed; right: 22px; bottom: 26px; width: 44px; height: 44px;
  border-radius: 50%; border: 1px solid var(--border); background: var(--accent); color: #fff;
  font-size: 20px; line-height: 1; cursor: pointer; z-index: 200; box-shadow: 0 4px 14px rgba(0,0,0,.35);
  opacity: 0; visibility: hidden; transform: translateY(8px); transition: opacity .18s, transform .18s, visibility .18s; }
.back-top.show { opacity: .92; visibility: visible; transform: translateY(0); }
.back-top:hover { opacity: 1; background: var(--accent2); }

/* result */
.result-card { min-height: 400px; }
.result-area { }
.placeholder { color: var(--muted); padding: 60px 20px; text-align: center; border: 1.5px dashed var(--border); border-radius: 12px; }
.result-loading { padding: 80px 20px; display: flex; flex-direction: column; align-items: center; gap: 14px; color: var(--muted); }
.result-err { color: var(--bad); padding: 30px; background: rgba(120,0,0,.15); border-radius: 10px; }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.compare figure { margin: 0; }
.compare figcaption { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.compare img, .compare video { width: 100%; border-radius: 10px; border: 1px solid var(--border); cursor: zoom-in; background: var(--panel2); }
.stats { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.stat { font-size: 12px; color: var(--text); background: var(--panel2); border: 1px solid var(--border); padding: 4px 11px; border-radius: 14px; }
.result-link { display: inline-block; margin-top: 12px; color: var(--accent); font-size: 13px; text-decoration: none; }

/* style 列表（管理弹窗内） */
.style-list { display: flex; flex-direction: column; gap: 8px; max-height: 60vh; overflow-y: auto; margin-top: 4px; }
.style-item { display: grid; grid-template-columns: 130px 1fr auto auto; align-items: center; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--panel2); }
.style-item .name { font-weight: 600; }
.style-item .k { color: var(--muted); font-size: 11px; font-weight: 400; margin-top: 2px; }
.style-item .style-prompt { color: var(--muted); font-size: 11.5px; line-height: 1.4; }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex;
  align-items: center; justify-content: center; z-index: 50; }
.modal.hidden { display: none; }
.modal-card { width: 620px; max-width: 92vw; max-height: 90vh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 22px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-head h3 { margin: 0; }
.modal-card label { display: block; margin: 12px 0 0; color: var(--muted); font-size: 13px; }
.modal-card input, .modal-card textarea { margin-top: 5px; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }

/* lightbox */
#lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: none;
  align-items: center; justify-content: center; z-index: 100; cursor: zoom-out; }
#lightbox.show { display: flex; }
#lightbox img { max-width: 92vw; max-height: 92vh; border-radius: 8px; }

/* ---- CSAM 审核子表 ---- */
.csam-subnav { display: flex; gap: 8px; margin: 4px 0 10px; }
.csam-subtab { background: var(--panel2); border: 1px solid var(--border); color: var(--muted);
  padding: 7px 16px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.csam-subtab:hover { border-color: var(--accent); }
.csam-subtab.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.csam-subtab .cnt { opacity: .8; font-weight: 400; margin-left: 2px; }
.csam-desc { color: var(--muted); font-size: 12px; line-height: 1.5; margin: 0 0 12px;
  padding: 8px 12px; background: var(--panel); border: 1px solid var(--border);
  border-left: 3px solid var(--warn); border-radius: 6px; }
.csam-desc b { color: var(--text); }

/* ---- 飞书 SSO 登录页 ---- */
.pwform { display: flex; flex-direction: column; gap: 12px; }
.pwform.hidden { display: none; }
.btn-feishu { display: block; text-align: center; text-decoration: none;
  background: var(--accent); color: #fff; font-weight: 600;
  padding: 11px 12px; border-radius: 8px; }
.btn-feishu:hover { background: var(--accent2); }
.login-or { text-align: center; color: var(--muted); font-size: 12px; margin: 12px 0 4px; }
.fallback-link { display: block; text-align: center; color: var(--muted);
  text-decoration: none; font-size: 12px; margin-top: 10px; }
.fallback-link:hover { color: var(--text); }

/* ---- 门户：应用侧边栏 + 嵌入 ---- */
.portal { display: flex; min-height: 100vh; }
.app-rail { width: 92px; flex: 0 0 92px; background: var(--panel); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 14px 0; position: sticky; top: 0; height: 100vh; }
.rail-brand { display: flex; flex-direction: column; align-items: center; gap: 6px; font-weight: 700; font-size: 13px; letter-spacing: .04em; margin-bottom: 18px; }
.rail-logo-img { width: 40px; height: 40px; border-radius: 11px; box-shadow: 0 6px 16px -6px rgba(55,140,255,.5); }
.rail-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.rail-item { background: transparent; border: none; color: var(--muted); padding: 11px 4px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 5px; border-left: 3px solid transparent; font-size: 12px; }
.rail-item .ri-ic { font-size: 19px; }
.rail-item:hover { color: var(--text); background: var(--panel2); }
.rail-item.active { color: var(--accent); border-left-color: var(--accent); background: var(--panel2); }
.rail-logout { margin-top: auto; text-align: center; color: var(--muted); text-decoration: none; font-size: 12px; padding: 8px; }
.rail-logout:hover { color: var(--text); }
.portal-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-pane { display: none; flex: 1; min-width: 0; }
.app-pane.active { display: block; }
.pane-head { display: flex; align-items: center; gap: 12px; padding: 13px 20px; border-bottom: 1px solid var(--border); }
.pane-head h2 { margin: 0; font-size: 18px; }
.auto-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; user-select: none; }
.auto-toggle input { accent-color: var(--accent, #5b8cff); cursor: pointer; }
.auto-toggle:hover { color: var(--text); }
.embed-status { padding: 10px 20px; color: var(--muted); }
.embed-frame { width: 100%; height: calc(100vh - 56px); border: 0; display: block; background: #fff; }
.placeholder-pane { padding: 64px 20px; text-align: center; color: var(--muted); font-size: 16px; line-height: 1.8; }
