:root {
  --bg: #f4f5f7; --panel: #fff; --line: #e3e6ea; --line2: #eef0f3; --text: #1c2430; --muted: #66707d;
  --faint: #98a1ad; --accent: #1f4e5f; --accent2: #2f7186; --accent-bg: #e8f1f4; --danger: #b42318;
  --danger-bg: #fdecea; --warn: #a15c07; --warn-bg: #fff4e0; --ok: #1b7a43; --ok-bg: #e6f4ec;
  --info: #3b5b8c; --info-bg: #eaf0fa; --radius: 8px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --font: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 var(--font); color: var(--text); background: var(--bg); display: flex; flex-direction: column; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent2); }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h2 { font-size: 18px; } h3 { font-size: 15px; } h4 { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: 12px; } .mono { font-family: var(--mono); }
.row { display: flex; align-items: center; gap: 8px; } .wrap { flex-wrap: wrap; } .grow { flex: 1; min-width: 0; }
.col { display: flex; flex-direction: column; gap: 8px; } .gap16 { gap: 16px; } .between { justify-content: space-between; }
.hidden { display: none !important; } .ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- topbar */
.topbar { height: 52px; background: var(--panel); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 18px; padding: 0 16px; flex: none; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; color: var(--accent); }
nav { display: flex; gap: 2px; height: 100%; }
nav a { display: flex; align-items: center; gap: 6px; padding: 0 12px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; font-weight: 500; }
nav a:hover { color: var(--text); }
nav a.active { color: var(--accent); border-bottom-color: var(--accent); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.jobbar { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); max-width: 340px; }
.jobbar .bar { width: 90px; height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.jobbar .bar i { display: block; height: 100%; background: var(--accent2); transition: width .3s; }
.switch { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; user-select: none; }

/* ---------- buttons & inputs */
.btn { border: 1px solid var(--line); background: var(--panel); border-radius: 6px; padding: 6px 12px; cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { border-color: #c9ced5; background: #fafbfc; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent2); }
.btn.danger { color: var(--danger); border-color: #f1c4bf; }
.btn.danger:hover { background: var(--danger-bg); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--line2); }
.btn.sm { padding: 3px 8px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
.iconbtn { border: none; background: transparent; cursor: pointer; padding: 2px 6px; border-radius: 4px; color: var(--muted); }
.iconbtn:hover { background: var(--line2); color: var(--text); }
input[type=text], input[type=number], input[type=search], select, textarea { border: 1px solid var(--line); border-radius: 6px; padding: 6px 9px; background: #fff; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent2); box-shadow: 0 0 0 3px rgba(47,113,134,.12); }
textarea { resize: vertical; width: 100%; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 500; }
label.field > input, label.field > textarea, label.field > select { font-size: 14px; color: var(--text); font-weight: 400; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg button { border: none; background: #fff; padding: 5px 11px; cursor: pointer; border-right: 1px solid var(--line); font-size: 13px; }
.seg button:last-child { border-right: none; }
.seg button.on { background: var(--accent); color: #fff; }

/* ---------- layout */
main { flex: 1; min-height: 0; overflow: hidden; }
.layout3 { display: grid; grid-template-columns: 290px minmax(360px, 1fr) 460px; height: 100%; }
.layout2 { display: grid; grid-template-columns: 300px 1fr; height: 100%; }
.layout-tree { display: grid; grid-template-columns: 260px minmax(380px, 1fr) 420px; height: 100%; }
.pane { overflow: auto; min-height: 0; background: var(--panel); border-right: 1px solid var(--line); }
.pane.plain { background: var(--bg); }
.pane:last-child { border-right: none; }
.pane-head { position: sticky; top: 0; z-index: 2; background: inherit; padding: 12px 14px; border-bottom: 1px solid var(--line2); display: flex; flex-direction: column; gap: 8px; }
.pane-body { padding: 12px 14px; }
.page { padding: 18px 22px; overflow: auto; height: 100%; }
.page-narrow { max-width: 1100px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.empty b { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }
hr.sep { border: none; border-top: 1px solid var(--line2); margin: 12px 0; }

/* ---------- badges & chips */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; padding: 1px 7px; border-radius: 10px; background: var(--line2); color: var(--muted); font-weight: 600; white-space: nowrap; }
.badge.high { background: var(--danger-bg); color: var(--danger); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.mode-locked { background: #eceef1; color: #4b5563; } .badge.mode-suggest { background: var(--info-bg); color: var(--info); } .badge.mode-auto { background: var(--ok-bg); color: var(--ok); }
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 2px 8px; border-radius: 12px; border: 1px solid var(--line); background: #fff; white-space: nowrap; max-width: 100%; }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.chip.filter { background: var(--accent-bg); border-color: #c9dfe6; }
.chip.ev-verified { border-color: #bfe3cc; } .chip.ev-partial { border-color: #f3d6a5; background: #fffaf0; } .chip.ev-unverified { border-color: #f1c4bf; background: #fff6f5; }
.ev { display: inline-block; width: 16px; height: 16px; line-height: 16px; text-align: center; border-radius: 50%; font-size: 10px; font-weight: 700; cursor: pointer; flex: none; }
.ev.verified { background: var(--ok-bg); color: var(--ok); } .ev.partial { background: var(--warn-bg); color: var(--warn); } .ev.unverified { background: var(--danger-bg); color: var(--danger); } .ev.none { background: var(--line2); color: var(--faint); }
.conf { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: var(--muted); }
.conf .meter { width: 38px; height: 5px; border-radius: 3px; background: var(--line); overflow: hidden; }
.conf .meter i { display: block; height: 100%; }
.stale { color: var(--warn); font-weight: 700; }

/* ---------- forest (left pane) */
.tree-block { border-bottom: 1px solid var(--line2); padding: 8px 6px 10px; }
.tree-title { display: flex; align-items: center; gap: 6px; padding: 4px 8px; font-weight: 700; font-size: 13px; cursor: pointer; }
.tree-title .swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.node-row { display: flex; align-items: center; gap: 4px; padding: 3px 8px 3px 0; border-radius: 5px; cursor: pointer; font-size: 13px; user-select: none; }
.node-row:hover { background: var(--line2); }
.node-row.active { background: var(--accent-bg); color: var(--accent); font-weight: 600; }
.node-row.drop { outline: 2px dashed var(--accent2); background: var(--accent-bg); }
.node-row .caret { width: 16px; text-align: center; color: var(--faint); flex: none; font-size: 10px; }
.node-row .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node-row .count { font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums; }
.node-row .ai { font-size: 9px; color: var(--accent2); border: 1px solid #c9dfe6; border-radius: 3px; padding: 0 3px; }
.node-row.unplaced .name { color: var(--warn); font-style: italic; }

/* ---------- candidate list */
.searchbar { display: flex; gap: 6px; }
.searchbar input { flex: 1; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.cand { display: flex; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line2); cursor: pointer; background: var(--panel); }
.cand:hover { background: #fafbfc; }
.cand.sel { background: var(--accent-bg); box-shadow: inset 3px 0 0 var(--accent); }
.cand .who { font-weight: 600; }
.cand .head { color: var(--muted); font-size: 13px; }
.cand .chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.cand .why { font-size: 12px; color: var(--accent2); margin-top: 4px; }
.cand.dragging { opacity: .5; }
.cand .status-err { color: var(--danger); font-size: 12px; }
.cand .status-run { color: var(--info); font-size: 12px; }
.listinfo { padding: 8px 14px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line2); background: #fbfbfc; display: flex; gap: 8px; align-items: center; }

/* ---------- detail */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); padding: 0 14px; position: sticky; top: 0; background: var(--panel); z-index: 3; overflow-x: auto; }
.tabs button { border: none; background: none; padding: 10px 10px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; font-weight: 500; white-space: nowrap; }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); }
.tabs .n { font-size: 10px; background: var(--danger-bg); color: var(--danger); border-radius: 8px; padding: 0 5px; margin-left: 3px; }
.d-head { padding: 14px; border-bottom: 1px solid var(--line2); }
.d-head h2 { font-size: 19px; }
.section { padding: 12px 14px; border-bottom: 1px solid var(--line2); }
.section > h4 { margin-bottom: 8px; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 4px 10px; font-size: 13px; }
.kv > div:nth-child(odd) { color: var(--muted); }
.job { display: grid; grid-template-columns: 16px 1fr; gap: 8px; padding: 8px 0; border-bottom: 1px dashed var(--line2); }
.job:last-child { border-bottom: none; }
.job .t { font-weight: 600; } .job .p { font-size: 12px; color: var(--muted); }
.job ul { margin: 4px 0 0; padding-left: 18px; font-size: 13px; }
.assign { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 10px; }
.assign .tname { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 13px; }
.assign .path { font-size: 14px; margin: 6px 0 2px; }
.assign .reason { font-size: 12px; color: var(--muted); }
.assign .sec { display: flex; align-items: center; gap: 6px; font-size: 12px; margin-top: 6px; color: var(--muted); }
.score-big { font-size: 28px; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.rubric-row { display: grid; grid-template-columns: 1fr 110px; gap: 4px 10px; padding: 6px 0; border-bottom: 1px dashed var(--line2); font-size: 13px; }
.rubric-row .bar5 { display: flex; gap: 2px; align-items: center; } .bar5 i { width: 16px; height: 8px; background: var(--line); border-radius: 2px; } .bar5 i.on { background: var(--accent2); }
.flag { border-left: 3px solid var(--line); padding: 6px 10px; margin-bottom: 8px; background: #fbfbfc; border-radius: 0 6px 6px 0; }
.flag.high { border-color: var(--danger); background: var(--danger-bg); } .flag.warn { border-color: #e0a443; background: var(--warn-bg); } .flag.info { border-color: #8aa4cc; background: var(--info-bg); }
.flag .ft { font-weight: 600; font-size: 13px; } .flag .fd { font-size: 12px; color: #3b4552; margin-top: 2px; }
.rawtext { white-space: pre-wrap; font-family: var(--mono); font-size: 12px; line-height: 1.55; background: #fbfbfc; border: 1px solid var(--line2); border-radius: 6px; padding: 10px; }
.rawtext mark { background: #ffe58a; border-radius: 2px; }
.hiddenbox { border: 1px solid #f1c4bf; background: var(--danger-bg); border-radius: 6px; padding: 8px 10px; font-size: 12px; color: #7a271a; white-space: pre-wrap; word-break: break-word; }
.q { padding: 8px 0; border-bottom: 1px dashed var(--line2); } .q .qq { font-weight: 600; } .q .qm { font-size: 12px; color: var(--muted); }

/* ---------- tree editor */
.tree-list-item { padding: 10px 12px; border-radius: 6px; cursor: pointer; border: 1px solid transparent; margin-bottom: 4px; }
.tree-list-item:hover { background: var(--line2); }
.tree-list-item.on { background: var(--accent-bg); border-color: #c9dfe6; }
.outline .node-row { padding: 5px 8px 5px 0; }
.outline .node-row .tools { display: none; gap: 2px; }
.outline .node-row:hover .tools, .outline .node-row.active .tools { display: flex; }
.outline .node-row .grip { cursor: grab; color: var(--faint); padding: 0 2px; }
.inherit { border: 1px dashed var(--line); border-radius: 6px; padding: 8px 10px; background: #fbfbfc; font-size: 13px; }
.inherit .from { font-size: 11px; color: var(--faint); }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 6px 8px; border-bottom: 1px solid var(--line2); vertical-align: top; }
.tbl tr:hover td { background: #fbfbfc; }
.tbl input, .tbl select { width: 100%; padding: 4px 6px; font-size: 13px; }
.hist { font-size: 12px; padding: 6px 0; border-bottom: 1px dashed var(--line2); }

/* ---------- proposals */
.prop { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); padding: 14px; margin-bottom: 12px; box-shadow: var(--shadow); }
.prop .kind { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--accent2); }
.prop .pv { font-size: 15px; font-weight: 600; margin: 4px 0; }
.prop .why { font-size: 13px; color: var(--muted); }
.mini-tree { font-size: 13px; margin: 8px 0 0; padding-left: 0; list-style: none; }
.mini-tree ul { list-style: none; padding-left: 18px; margin: 0; border-left: 1px dashed var(--line); }
.mini-tree li { padding: 2px 0 2px 6px; }
.mini-tree .crit { color: var(--faint); font-size: 12px; }

/* ---------- stats */
.statgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat .v { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; } .stat .l { font-size: 12px; color: var(--muted); }
.hbar { display: grid; grid-template-columns: minmax(120px, 220px) 1fr 40px; gap: 8px; align-items: center; font-size: 13px; padding: 2px 0; }
.hbar .track { height: 10px; background: var(--line2); border-radius: 5px; overflow: hidden; } .hbar .track i { display: block; height: 100%; border-radius: 5px; }
.hbar .n { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }

/* ---------- jd / compare */
.scorebar { width: 100px; height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; display: inline-block; vertical-align: middle; }
.scorebar i { display: block; height: 100%; }
.cmp { border-collapse: collapse; width: 100%; font-size: 13px; background: var(--panel); }
.cmp th, .cmp td { border: 1px solid var(--line); padding: 8px 10px; vertical-align: top; text-align: left; }
.cmp th { background: #fafbfc; width: 150px; color: var(--muted); font-weight: 600; }

/* ---------- modal & toast */
.backdrop { position: fixed; inset: 0; background: rgba(16,24,40,.38); display: flex; align-items: flex-start; justify-content: center; padding-top: 8vh; z-index: 50; }
.modal { background: var(--panel); border-radius: 10px; width: min(560px, 94vw); max-height: 84vh; overflow: auto; box-shadow: 0 20px 50px rgba(0,0,0,.2); }
.modal.wide { width: min(820px, 96vw); }
.modal-h { padding: 14px 18px; border-bottom: 1px solid var(--line2); display: flex; justify-content: space-between; align-items: center; }
.modal-b { padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.modal-f { padding: 12px 18px; border-top: 1px solid var(--line2); display: flex; justify-content: flex-end; gap: 8px; }
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: #1c2430; color: #fff; padding: 10px 14px; border-radius: 8px; font-size: 13px; max-width: 380px; box-shadow: 0 6px 20px rgba(0,0,0,.2); animation: slidein .2s ease-out; }
.toast.err { background: var(--danger); } .toast.ok { background: #14532d; }
@keyframes slidein { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.drop-overlay { position: fixed; inset: 0; background: rgba(31,78,95,.14); border: 3px dashed var(--accent2); z-index: 40; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.drop-overlay div { background: #fff; padding: 18px 28px; border-radius: 10px; font-weight: 600; color: var(--accent); box-shadow: var(--shadow); }
.spinner { width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--accent2); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.notice { background: var(--warn-bg); border: 1px solid #f3d6a5; color: #6b3d05; padding: 10px 14px; border-radius: 8px; font-size: 13px; }
.notice.info { background: var(--info-bg); border-color: #c9d6ee; color: #23395d; }
@media (max-width: 1280px) { .layout3 { grid-template-columns: 250px minmax(320px, 1fr) 400px; } .layout-tree { grid-template-columns: 220px 1fr 360px; } }
