/* ============ OPL 知识清洗工作台 ============ */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --line: #e3e8ef;
  --text: #2c3e50;
  --muted: #8a97a6;
  --accent: #2f6fed;
  --c-title: #e74c3c;
  --c-doctype: #e67e22;
  --c-meta: #2f6fed;
  --c-content: #16a085;
  --c-none: #95a5a6;
  --sel: #ffd54a;
}
html, body { height: 100%; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px;
  display: flex; flex-direction: column; overflow: hidden;
}
.hidden { display: none !important; }
.spacer { flex: 1; }

/* ---------- 顶栏 ---------- */
#topbar {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel); border-bottom: 1px solid var(--line);
  padding: 8px 14px; flex: 0 0 auto; z-index: 10;
}
.brand { font-weight: 700; font-size: 15px; color: var(--accent); white-space: nowrap; }
.doc-name {
  color: var(--muted); font-size: 13px; max-width: 300px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tb-field { display: flex; align-items: center; gap: 6px; }
.tb-field label { color: var(--muted); font-size: 12px; }
.chip {
  font-size: 12px; padding: 3px 10px; border-radius: 10px;
  background: #eef4ff; color: var(--accent); white-space: nowrap;
}
.chip.warn { background: #fff4e5; color: #b26a00; }
.chip.stale { background: #fdecea; color: #c0392b; }

/* ---------- 按钮 ---------- */
.btn {
  border: 1px solid var(--line); background: #fff; color: var(--text);
  border-radius: 6px; padding: 5px 12px; font-size: 13px; cursor: pointer;
  transition: all .15s; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { opacity: .88; color: #fff; }
.btn.ghost { background: transparent; }
.btn.danger:hover { border-color: #e74c3c; color: #e74c3c; }
.btn.big { padding: 10px 28px; font-size: 15px; }
.btn.sm { padding: 2px 9px; font-size: 12px; }

/* ---------- 文件队列条 ---------- */
.doc-strip {
  display: flex; align-items: center; gap: 6px; flex: 0 0 auto;
  background: #fafbfd; border-bottom: 1px solid var(--line);
  padding: 5px 12px; overflow-x: auto; z-index: 9;
}
.doc-tab {
  display: flex; align-items: center; gap: 6px; flex: 0 0 auto;
  border: 1px solid var(--line); background: #fff; border-radius: 14px;
  padding: 3px 12px; font-size: 12px; cursor: pointer; color: var(--text);
  max-width: 320px;
}
.doc-tab:hover { border-color: var(--accent); }
.doc-tab.active { border-color: var(--accent); background: #eef4ff; color: var(--accent); font-weight: 600; }
.dt-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dt-cat {
  flex: 0 0 auto; font-size: 10.5px; padding: 1px 7px; border-radius: 9px;
  background: #eaf7f2; color: #0e8a6d;
}
.dt-mark { flex: 0 0 auto; font-size: 11px; }
.dt-mark.saved { color: #16a085; }
.dt-mark.dirty { color: #e67e22; }
.dt-close {
  flex: 0 0 auto; margin-left: 2px; width: 15px; height: 15px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; font-size: 10px; line-height: 1; color: var(--muted);
  cursor: pointer;
}
.dt-close:hover { background: #f0d3d3; color: #c0392b; }
.doc-tab.active .dt-close { color: var(--accent); }
.doc-tab.active .dt-close:hover { background: #d8e4fb; color: #c0392b; }

/* ---------- 分段开关 ---------- */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg-btn {
  border: none; background: #fff; padding: 3px 10px; font-size: 12px;
  cursor: pointer; color: var(--muted);
}
.seg-btn + .seg-btn { border-left: 1px solid var(--line); }
.seg-btn.active { background: var(--accent); color: #fff; }

/* ---------- 落地页 ---------- */
#landing { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px; }
#dropzone {
  width: min(680px, 92%); background: var(--panel);
  border: 2px dashed #c6d2e0; border-radius: 16px;
  padding: 48px 40px; text-align: center; transition: all .2s;
}
#dropzone.drag { border-color: var(--accent); background: #f0f5ff; }
.dz-icon { font-size: 44px; }
#dropzone h2 { margin: 12px 0 6px; font-size: 18px; }
#dropzone p { color: var(--muted); margin-bottom: 20px; }
.samples { margin-top: 30px; border-top: 1px solid var(--line); padding-top: 18px; }
.samples h3 { font-size: 13px; color: var(--muted); margin-bottom: 10px; font-weight: 500; }
.sample-list { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.sample-btn {
  border: 1px solid var(--line); border-radius: 14px; background: #fafbfd;
  padding: 5px 12px; font-size: 12px; cursor: pointer; color: var(--text);
}
.sample-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- 工作区布局 ---------- */
#main { flex: 1; display: flex; flex-direction: column; min-height: 0; }
#workspace { flex: 1; display: flex; min-height: 0; }
#leftPane { flex: 1.15; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
#splitter { flex: 0 0 5px; background: var(--line); cursor: col-resize; }
#splitter:hover { background: var(--accent); }
#rightPane {
  flex: 1; display: flex; flex-direction: column;
  min-width: 320px; min-height: 0; background: var(--panel);
}

.pane-toolbar {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px; border-bottom: 1px solid var(--line);
  background: #fafbfd; flex: 0 0 auto; min-height: 38px;
}
.page-nav { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.mode-hint { color: var(--muted); font-size: 12px; }

.tabs { display: flex; gap: 4px; }
.tab {
  border: none; background: transparent; padding: 6px 14px; font-size: 13px;
  cursor: pointer; border-radius: 6px; color: var(--muted);
}
.tab.active { background: #eef4ff; color: var(--accent); font-weight: 600; }
.pane-body { flex: 1; overflow: auto; padding: 14px; min-height: 0; }
#rawView {
  font-family: Consolas, "Courier New", monospace; font-size: 12.5px; line-height: 1.55;
  border: none; outline: none; resize: none; background: #fbfcfe; color: var(--text);
  white-space: pre; width: 100%;
}

/* ---------- 页面预览 ---------- */
#pageArea {
  flex: 1; overflow: auto; min-height: 0;
  display: flex; align-items: flex-start; justify-content: center; padding: 18px;
}
.page-wrap { position: relative; width: 100%; max-width: 980px; }
.page-img { width: 100%; display: block; border: 1px solid var(--line); box-shadow: 0 2px 10px rgba(0,0,0,.06); }
.slide-canvas {
  position: relative; width: 100%; border: 1px solid var(--line);
  background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.06); overflow: hidden;
}
.canvas-txt {
  position: absolute; overflow: hidden; font-size: 10px; line-height: 1.25;
  color: #333; word-break: break-all; padding: 1px 2px;
}
.box-layer { position: absolute; inset: 0; }

.flow { width: 100%; max-width: 980px; background: var(--panel); border: 1px solid var(--line); padding: 22px 26px; }
.flow-block {
  position: relative; padding: 7px 12px; margin-bottom: 4px; border-radius: 4px;
  border: 1.5px solid transparent; cursor: pointer; line-height: 1.6;
}
.flow-block:hover { background: #f6f9ff; }
.flow-block.heading { font-weight: 700; font-size: 15.5px; margin-top: 10px; }
.flow-block.assigned { background: #f7fdfb; }
.flow-block.unassigned { border-style: dashed; border-color: #cfd8e2; }
.flow-block table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.flow-block td { border: 1px solid #d7dee8; padding: 4px 8px; }

/* ---------- 框体 ---------- */
.box {
  position: absolute; cursor: pointer;
  border: 2px solid var(--c-none);
  border-radius: 3px;
  transition: box-shadow .12s, border-color .12s;
}
.box:hover { border-color: var(--accent); }
.box .box-fill { position: absolute; inset: 0; opacity: .07; background: currentColor; }
.box .badge {
  position: absolute; top: -9px; left: -2px; max-width: 96%;
  font-size: 10px; line-height: 1; padding: 3px 6px; border-radius: 3px;
  color: #fff; background: var(--c-none); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; pointer-events: none;
}
.box.assigned { border-style: solid; }
.box.unassigned {
  border-style: dashed; border-width: 1px; opacity: .55;
}
.box.unassigned:hover { opacity: 1; }
/* 覆盖整页的大框：不画边框/填充，仅保留角标，避免遮挡正文 */
.box.box-tag {
  border: none !important; background: transparent;
}
.box.box-tag .box-fill { display: none; }
.box.box-tag .tag-badge {
  top: 2px; left: 2px; opacity: .9;
}
.box.selected { border-color: var(--sel) !important; box-shadow: 0 0 0 2px rgba(255,213,74,.55); z-index: 5; opacity: 1; }
.box.selected .badge { background: #b8860b !important; }
.flow-block.selected { border-color: var(--sel); box-shadow: 0 0 0 2px rgba(255,213,74,.55); }
.flow-badge {
  position: absolute; top: -8px; right: 6px;
  color: #fff; font-size: 10px; padding: 2px 6px; border-radius: 3px;
  pointer-events: none;
}

/* 拖拽画框 */
.rect-draw {
  position: absolute; border: 2px dashed var(--accent);
  background: rgba(47,111,237,.08); pointer-events: none; z-index: 6;
}

/* ---------- 检查器 ---------- */
#inspector {
  flex: 0 0 auto; border-top: 2px solid var(--accent);
  background: var(--panel); padding: 8px 14px 10px;
  max-height: 240px; overflow: auto;
}
.insp-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.insp-head span { font-weight: 600; font-size: 13px; }
.insp-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.insp-row label { flex: 0 0 78px; color: var(--muted); font-size: 12.5px; }
.insp-row select, .insp-row input {
  flex: 1; border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; font-size: 13px;
}
.insp-row textarea {
  flex: 1; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px;
  font-size: 13px; font-family: inherit; resize: vertical;
}
.insp-tip { color: var(--muted); font-size: 11.5px; }

/* ---------- JSON 树 ---------- */
.jtree { font-family: Consolas, "Courier New", monospace; font-size: 13px; line-height: 1.8; }
.jnode { margin-left: 0; }
.jchildren { margin-left: 20px; border-left: 1px dotted #d5dde8; padding-left: 12px; }
.jrow { display: flex; align-items: center; gap: 6px; min-height: 26px; }
.jkey { color: #a626a4; white-space: nowrap; font-family: Consolas, "Microsoft YaHei", sans-serif; }
.jkey::after { content: "："; color: var(--muted); }
.jbrace { color: var(--muted); }
.jval {
  flex: 1; border: 1px solid transparent; border-radius: 4px; padding: 2px 6px;
  font-family: inherit; font-size: 13px; color: #1a7f37; background: transparent;
}
.jval:hover { border-color: var(--line); background: #fff; }
.jval:focus { outline: none; border-color: var(--accent); background: #fff; }
.jdel {
  border: none; background: transparent; color: #ccd4dd; cursor: pointer; font-size: 12px;
}
.jdel:hover { color: #e74c3c; }
.jadd {
  border: 1px dashed #c6d2e0; background: transparent; color: var(--muted);
  border-radius: 4px; padding: 1px 10px; font-size: 12px; cursor: pointer; margin: 2px 0;
}
.jadd:hover { color: var(--accent); border-color: var(--accent); }
.jbadge {
  flex: 0 0 auto; font-size: 10px; padding: 2px 7px; border-radius: 8px;
  background: #eef4ff; color: var(--accent); cursor: pointer; border: none;
  font-family: "Microsoft YaHei", sans-serif;
}
.jbadge:hover { background: var(--accent); color: #fff; }

/* ---------- 其它 ---------- */
#toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: #2c3e50; color: #fff; padding: 9px 18px; border-radius: 8px;
  font-size: 13px; z-index: 99; box-shadow: 0 4px 14px rgba(0,0,0,.25);
}
.toast.err { background: #c0392b; }
.loading {
  position: fixed; inset: 0; background: rgba(255,255,255,.72);
  display: flex; flex-direction: column; gap: 14px;
  align-items: center; justify-content: center; z-index: 98; font-size: 14px; color: var(--muted);
}
.spin {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid #d7e2f2; border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- v2 导入 / 设置 ---------- */
.import-actions { display:flex; flex-wrap:wrap; gap:10px; justify-content:center; }
.landing-mode { margin-top:14px; font-size:12.5px; color:var(--muted); }
.modal { position:fixed; inset:0; z-index:1000; background:rgba(20,28,40,.42); display:flex; align-items:center; justify-content:center; padding:24px; }
.modal.hidden { display:none; }
.modal-card { width:min(680px, 96vw); max-height:90vh; overflow:auto; background:#fff; border-radius:12px; box-shadow:0 18px 60px rgba(0,0,0,.22); padding:18px; }
.modal-head { display:flex; align-items:center; gap:12px; border-bottom:1px solid var(--line); padding-bottom:10px; margin-bottom:12px; }
.modal-head h3 { margin:0; font-size:17px; }
.setting-row { display:flex; gap:12px; align-items:center; margin:10px 0; }
.setting-row > label:first-child { flex:0 0 100px; color:var(--muted); font-size:13px; }
.setting-row select, .setting-row input:not([type=checkbox]) { flex:1; border:1px solid var(--line); border-radius:6px; padding:7px 9px; font-size:13px; min-width:0; }
.setting-row .check { flex:1; font-size:13px; }
.setting-note { background:#f7f9fc; border:1px solid var(--line); border-radius:7px; padding:10px 12px; font-size:12px; color:var(--muted); line-height:1.6; }
.modal-actions { display:flex; align-items:center; gap:10px; margin-top:16px; }
.doc-image { display:block; max-width:100%; max-height:100%; object-fit:contain; }
.canvas-media { position:absolute; overflow:hidden; }
.flow-image { display:block; max-width:100%; max-height:520px; margin:4px auto; object-fit:contain; }
.preview-warning { color:#b26a00; }
