/* 配色与《怡小保AI化落地方案》及怡小保演示 Demo 一致 */
:root {
  --bg: #EEF3FA; --surface: #FFFFFF; --surface-2: #F5F8FC; --surface-3: #EBF1F9;
  --ink: #14233A; --muted: #56657C; --faint: #8B98AC; --line: #D6E1F0; --line-soft: #E6EDF7;
  --brand: #2F6FDB; --brand-2: #4C8BF5; --brand-deep: #1D4E9E; --brand-soft: #E4EEFD; --on-brand: #FFFFFF;
  --ok: #1F8A55; --ok-soft: #DDF2E6; --warn: #A86F08; --warn-soft: #F8EDD3; --bad: #C2412D; --bad-soft: #FBE3DE;
  --shadow-sm: 0 1px 2px rgba(20, 35, 58, .06);
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.6 var(--sans); color: var(--ink); background: var(--bg); min-height: 100vh; -webkit-font-smoothing: antialiased; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }
:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 2px; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
.muted { color: var(--faint); font-size: 12px; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 28px; background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; color: #fff; font-size: 21px; font-weight: 600;
  background: linear-gradient(135deg, var(--brand-2), var(--brand-deep)); box-shadow: 0 6px 16px -4px rgba(47, 111, 219, .5); }
.brand h1 { font-size: 19px; font-weight: 650; }
.brand p { font-size: 13px; color: var(--muted); }
.top-meta { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 7px; font: 12px var(--mono); color: var(--muted); background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.chip.ok .dot { background: var(--ok); } .chip.bad .dot { background: var(--bad); }

.rootbar { display: flex; align-items: center; gap: 10px; padding: 14px 28px; }
.rootbar label { font-size: 13px; color: var(--muted); white-space: nowrap; }
.rootbar input { flex: 1; min-width: 0; font: 13px var(--mono); padding: 8px 11px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 13px; border-radius: 7px; border: 1px solid var(--line);
  background: var(--surface); color: var(--brand-deep); font-size: 13px; text-decoration: none; white-space: nowrap; transition: border-color .15s, background .15s; }
.btn:hover:not(:disabled) { border-color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); width: 100%; padding: 11px; font-size: 14px; }
.btn.primary:hover:not(:disabled) { background: var(--brand-deep); }
.link { border: 0; background: none; color: var(--brand); padding: 2px 0; font-size: 13px; }

.layout { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 18px; padding: 0 28px 28px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-sm); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line-soft); }
.panel-head h2 { font-size: 15px; font-weight: 600; }

.folders-panel { position: sticky; top: 14px; display: flex; flex-direction: column; max-height: calc(100vh - 28px); }
.folder-tools { padding: 12px 16px 6px; display: grid; gap: 8px; }
.folder-tools input { padding: 7px 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-2); }
.tool-row { display: flex; gap: 16px; }
.folder-list { overflow: auto; flex: 1; padding: 4px 8px 8px; min-height: 120px; }
.tree-dir, .folder { padding-left: calc(4px + var(--depth, 0) * 18px); }
.tree-dir { display: flex; align-items: center; gap: 6px; padding-top: 6px; padding-bottom: 6px; padding-right: 8px; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--ink); }
.tree-dir:hover { background: var(--surface-2); }
.tree-dir small { margin-left: auto; font: 11px var(--mono); color: var(--faint); }
.dir-icon { font-size: 13px; }
.picked { font-size: 11px; font-weight: 500; color: var(--brand); background: var(--brand-soft); padding: 0 7px; border-radius: 999px; }
.twisty { width: 18px; height: 18px; flex: none; display: inline-grid; place-items: center; border: 0; background: none; padding: 0; color: var(--faint); font-size: 12px; border-radius: 4px; }
button.twisty:hover { background: var(--surface-3); color: var(--ink); }
.folder { display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; gap: 4px 6px; align-items: center; padding-top: 7px; padding-bottom: 7px; padding-right: 8px; border-radius: 8px; cursor: pointer; }
.folder:hover { background: var(--surface-2); }
.folder.active { background: var(--brand-soft); }
.folder.disabled { cursor: not-allowed; opacity: .55; }
.folder.disabled:hover { background: none; }
.folder input, .tree-dir input { width: 15px; height: 15px; flex: none; accent-color: var(--brand); margin: 0; }
.tree-dir.root { cursor: default; border-bottom: 1px solid var(--line-soft); border-radius: 8px 8px 0 0; margin-bottom: 2px; }
.folder-name { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-meta { grid-column: 3 / 5; font: 11px var(--mono); color: var(--faint); display: flex; gap: 8px; }
.folder-meta .warn { color: var(--warn); font-family: var(--sans); }
.progress-pill { font: 11px var(--mono); color: var(--muted); background: var(--surface-3); padding: 1px 7px; border-radius: 999px; }
.progress-pill.complete { background: var(--ok-soft); color: var(--ok); }
.progress-pill.has-error { background: var(--bad-soft); color: var(--bad); }
.run-box { border-bottom: 1px solid var(--line-soft); padding: 12px 16px 16px; display: grid; gap: 10px; }
.selection { font-size: 13px; color: var(--muted); }
.check { display: flex; gap: 7px; align-items: center; font-size: 12px; color: var(--muted); }
.check input { accent-color: var(--brand); }

.content { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; min-width: 0; }
.job { padding: 14px 16px; }
.job-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.job-head strong { margin-right: 10px; }
.job.error #job-meta { color: var(--bad); font-size: 13px; }
.bar { height: 6px; background: var(--surface-3); border-radius: 999px; overflow: hidden; margin: 12px 0 8px; }
.bar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--brand-2), var(--brand)); transition: width .4s; }
.running { margin: 0; padding: 0; list-style: none; display: grid; gap: 3px; font-size: 12px; color: var(--muted); }
.running li { display: flex; gap: 10px; }
.running li span:last-child { margin-left: auto; font-family: var(--mono); color: var(--faint); }

.metrics { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.metric { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 13px 15px; box-shadow: var(--shadow-sm); }
.metric small { display: block; font-size: 12px; color: var(--muted); }
.metric b { display: block; font-size: 24px; font-weight: 650; margin-top: 3px; font-variant-numeric: tabular-nums; }
.metric span { font-size: 11px; color: var(--faint); }
.metric.accent b { color: var(--brand); }

.results-head { flex-wrap: wrap; }
.spacer { flex: 1; }
.seg { display: inline-flex; background: var(--surface-3); border-radius: 8px; padding: 2px; }
.seg button { border: 0; background: none; padding: 5px 11px; border-radius: 6px; font-size: 13px; color: var(--muted); }
.seg button.active { background: var(--surface); color: var(--brand-deep); box-shadow: var(--shadow-sm); font-weight: 600; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); background: var(--surface-2); padding: 10px 12px; white-space: nowrap; }
td { padding: 10px 12px; border-top: 1px solid var(--line-soft); vertical-align: top; }
tbody tr { cursor: pointer; }
tbody tr:hover td { background: var(--surface-2); }
td small { display: block; font: 11px var(--mono); color: var(--faint); margin-top: 2px; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
th.num { text-align: right; }
td.desc { color: var(--muted); max-width: 360px; min-width: 220px; }
.file { font-weight: 500; display: block; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td.info-cell { min-width: 180px; max-width: 280px; }
.tag { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 999px; white-space: nowrap; }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.none { background: var(--surface-3); color: var(--faint); }
.error-text { color: var(--bad); }
.empty { padding: 40px 16px; text-align: center; color: var(--faint); }

dialog { width: min(980px, 94vw); border: 1px solid var(--line); border-radius: 14px; padding: 0; color: var(--ink); box-shadow: 0 30px 80px rgba(20, 35, 58, .25); }
dialog::backdrop { background: rgba(20, 35, 58, .35); backdrop-filter: blur(2px); }
.detail-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line-soft); }
.detail-head h3 { font-size: 16px; }
.close { border: 0; background: none; font-size: 26px; line-height: 1; color: var(--faint); }
.detail-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 18px; padding: 18px; }
.detail-body video { width: 100%; max-height: 70vh; background: #0F1726; border-radius: 8px; }
#detail-info { display: grid; gap: 12px; align-content: start; font-size: 13px; max-height: 70vh; overflow: auto; }
#detail-info h4 { margin: 0 0 6px; font-size: 13px; }
.cand { border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; }
.cand.hit { border-color: var(--ok); background: #F3FAF6; }
.cand-top { display: flex; justify-content: space-between; gap: 10px; font-weight: 600; }
.cand p { color: var(--muted); margin-top: 4px; }
.seek { display: block; width: 100%; text-align: left; border: 0; background: var(--surface-2); border-radius: 6px; padding: 5px 8px; margin-top: 5px; font-size: 12px; color: var(--muted); }
.seek code { color: var(--brand); margin-right: 6px; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 11px 20px; border-radius: 8px; font-size: 13px; z-index: 10; max-width: 90vw; }

@media (max-width: 1100px) { .metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; padding: 0 16px 16px; }
  .folders-panel { position: static; max-height: 60vh; }
  .topbar, .rootbar { padding-left: 16px; padding-right: 16px; }
  .detail-body { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* 只读查看模式：不显示识别相关操作 */
.view-only .run-box, .view-only #root-apply, .view-only #model-chip { display: none; }
.view-only .rootbar input { background: var(--surface-2); color: var(--muted); }
