/* ============ PBL 平台 · 蓝白科技风 ============ */
:root {
  --navy: #0b2a5b; --navy2: #0e3a7d;
  --blue: #2563eb; --blue2: #3b82f6; --blue-l: #dbeafe; --blue-xl: #eff6ff;
  --green: #16a34a; --green-l: #dcfce7;
  --orange: #d97706; --orange-l: #fef3c7;
  --red: #dc2626; --red-l: #fee2e2;
  --purple: #7c3aed; --purple-l: #ede9fe;
  --teal: #0d9488; --teal-l: #ccfbf1;
  --txt: #1e293b; --txt2: #64748b; --line: #e2e8f0;
  --bg: #f1f5fb; --card: #ffffff;
  --shadow: 0 1px 3px rgba(15,40,90,.08), 0 4px 14px rgba(15,40,90,.05);
  --glow: 0 0 12px rgba(59,130,246,.45);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: "PingFang SC","Microsoft YaHei","Hiragino Sans GB",sans-serif; font-size: 13.5px; color: var(--txt); background: var(--bg); }
a { color: var(--blue); text-decoration: none; cursor: pointer; }
button { font-family: inherit; }

/* ---------- 布局 ---------- */
#app { display: flex; flex-direction: column; height: 100vh; }
#topbar { height: 52px; display: flex; align-items: center; gap: 18px; padding: 0 18px;
  background: linear-gradient(90deg, #081f45 0%, #0e3a7d 55%, #10499b 100%); color: #fff; flex-shrink: 0; }
#topbar .logo { display: flex; align-items: center; gap: 8px; font-size: 15px; white-space: nowrap; }
#topbar .logo .sub { font-size: 11px; color: #9db8e8; margin-left: 6px; font-weight: normal; }
#topnav { display: flex; gap: 2px; flex: 1; }
#topnav a { color: #cfe0fb; padding: 6px 13px; border-radius: 6px; font-size: 13px; }
#topnav a:hover { background: rgba(255,255,255,.12); color: #fff; }
#topnav a.active { background: rgba(59,130,246,.35); color: #fff; box-shadow: inset 0 0 0 1px rgba(147,197,253,.4); }
.top-right { display: flex; gap: 10px; align-items: center; }
.kb-chip { font-size: 11.5px; background: rgba(22,163,74,.25); border: 1px solid rgba(74,222,128,.5); padding: 3px 10px; border-radius: 20px; cursor: pointer; }
.user-chip { font-size: 12px; background: rgba(255,255,255,.12); padding: 4px 12px; border-radius: 20px; }

#body { flex: 1; display: flex; min-height: 0; }
#sidebar { width: 208px; background: #fff; border-right: 1px solid var(--line); overflow-y: auto; flex-shrink: 0; padding: 10px 0; }
#main { flex: 1; overflow-y: auto; padding: 18px 22px; min-width: 0; }

/* ---------- 侧边菜单 ---------- */
.menu-group { margin-bottom: 4px; }
.menu-group > .mg-title { padding: 8px 18px 5px; font-size: 11px; color: #94a3b8; letter-spacing: 2px; }
.menu-item { display: flex; align-items: center; gap: 9px; padding: 8px 18px; cursor: pointer; color: #334155; font-size: 13px; border-left: 3px solid transparent; }
.menu-item:hover { background: var(--blue-xl); color: var(--blue); }
.menu-item.active { background: linear-gradient(90deg, var(--blue-xl), transparent); color: var(--blue); border-left-color: var(--blue); font-weight: 600; }
.menu-item .mi-ico { width: 16px; text-align: center; font-size: 14px; }
.menu-sub .menu-item { padding-left: 42px; font-size: 12.5px; }
.menu-item .badge { margin-left: auto; background: var(--red); color: #fff; font-size: 10px; border-radius: 9px; padding: 1px 6px; }

/* ---------- 通用组件 ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); }
.card .card-h { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 14px; }
.card .card-h .hint { font-weight: normal; font-size: 12px; color: var(--txt2); }
.card .card-b { padding: 14px 16px; }
.page-title { font-size: 19px; font-weight: 700; margin-bottom: 4px; display: flex; align-items: center; gap: 10px; }
.page-sub { color: var(--txt2); font-size: 12.5px; margin-bottom: 16px; }
.crumb { font-size: 12px; color: var(--txt2); margin-bottom: 10px; }
.crumb a { color: var(--txt2); } .crumb a:hover { color: var(--blue); }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: 1fr 1fr; } .g3 { grid-template-columns: repeat(3,1fr); }
.g4 { grid-template-columns: repeat(4,1fr); } .g21 { grid-template-columns: 2fr 1fr; }
.g12 { grid-template-columns: 1fr 2fr; }
.mt { margin-top: 14px; } .mb { margin-bottom: 14px; }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; color: var(--txt);
  padding: 6px 14px; border-radius: 7px; font-size: 12.5px; cursor: pointer; transition: all .15s; }
.btn:hover { border-color: var(--blue2); color: var(--blue); }
.btn.primary { background: linear-gradient(135deg, var(--blue2), var(--blue)); border: none; color: #fff; box-shadow: 0 2px 8px rgba(37,99,235,.35); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: rgba(255,255,255,.5); color: #fff; }
.btn.danger { background: var(--red); border: none; color: #fff; }
.btn.green { background: var(--green); border: none; color: #fff; }
.btn.sm { padding: 3px 10px; font-size: 12px; border-radius: 6px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.tag { display: inline-block; font-size: 11px; padding: 2px 9px; border-radius: 20px; background: var(--blue-l); color: var(--blue); margin-right: 4px; white-space: nowrap; }
.tag.green { background: var(--green-l); color: var(--green); }
.tag.orange { background: var(--orange-l); color: var(--orange); }
.tag.red { background: var(--red-l); color: var(--red); }
.tag.purple { background: var(--purple-l); color: var(--purple); }
.tag.teal { background: var(--teal-l); color: var(--teal); }
.tag.gray { background: #f1f5f9; color: var(--txt2); }
.tag.navy { background: var(--navy); color: #fff; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 12.8px; }
.tbl th { background: var(--blue-xl); color: var(--navy); text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); font-weight: 600; white-space: nowrap; }
.tbl td { padding: 8px 10px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.tbl tr:hover td { background: #f8faff; }
.tbl .num { font-variant-numeric: tabular-nums; }

input, select, textarea { font-family: inherit; font-size: 13px; border: 1px solid var(--line); border-radius: 7px; padding: 7px 10px; background: #fff; color: var(--txt); outline: none; width: 100%; }
input:focus, select:focus, textarea:focus { border-color: var(--blue2); box-shadow: 0 0 0 3px rgba(59,130,246,.15); }
textarea.code { font-family: "SF Mono", Consolas, monospace; font-size: 12px; line-height: 1.55; background: #f8fafc; }
label.fl { display: block; font-size: 12px; color: var(--txt2); margin: 10px 0 4px; }

/* KPI 卡 */
.kpi { padding: 14px 16px; position: relative; overflow: hidden; }
.kpi::after { content: ""; position: absolute; right: -22px; top: -22px; width: 86px; height: 86px; border-radius: 50%; background: var(--blue-xl); opacity: .8; }
.kpi .kv { font-size: 26px; font-weight: 700; color: var(--navy); font-variant-numeric: tabular-nums; }
.kpi .kl { font-size: 12px; color: var(--txt2); margin-top: 2px; }
.kpi .kd { font-size: 11px; margin-top: 4px; }
.kpi.warn .kv { color: var(--orange); } .kpi.bad .kv { color: var(--red); } .kpi.ok .kv { color: var(--green); }

/* 状态机步骤条 */
.stages { display: flex; gap: 0; align-items: center; margin: 6px 0 2px; }
.stage { flex: 1; text-align: center; position: relative; padding: 8px 2px 6px; }
.stage .dot { width: 26px; height: 26px; border-radius: 50%; margin: 0 auto 5px; display: flex; align-items: center; justify-content: center;
  background: #e2e8f0; color: #94a3b8; font-size: 12px; font-weight: 700; border: 2px solid #cbd5e1; }
.stage .nm { font-size: 12px; color: var(--txt2); }
.stage.done .dot { background: var(--green); border-color: var(--green); color: #fff; }
.stage.done .nm { color: var(--green); }
.stage.cur .dot { background: var(--blue); border-color: var(--blue); color: #fff; box-shadow: var(--glow); animation: pulse 1.8s infinite; }
.stage.cur .nm { color: var(--blue); font-weight: 700; }
.stage .bar { position: absolute; top: 20px; left: -50%; width: 100%; height: 2px; background: #cbd5e1; z-index: -1; }
.stage.done .bar, .stage.cur .bar { background: var(--blue2); }
.stage:first-child .bar { display: none; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 6px rgba(59,130,246,.5);} 50% { box-shadow: 0 0 16px rgba(59,130,246,.85);} }

/* 弹窗 / 抽屉 / Toast */
.modal-mask { position: fixed; inset: 0; background: rgba(8,25,60,.45); backdrop-filter: blur(2px); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal { background: #fff; border-radius: 12px; width: 560px; max-width: 92vw; max-height: 86vh; display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(8,25,60,.35); animation: pop .18s ease; }
.modal.lg { width: 860px; } .modal.xl { width: 1080px; }
.modal .m-h { padding: 14px 18px; border-bottom: 1px solid var(--line); font-weight: 700; font-size: 15px; display: flex; justify-content: space-between; align-items: center; }
.modal .m-b { padding: 16px 18px; overflow-y: auto; }
.modal .m-f { padding: 12px 18px; border-top: 1px solid var(--line); text-align: right; display: flex; gap: 10px; justify-content: flex-end; }
.m-h .x { cursor: pointer; color: #94a3b8; font-size: 18px; line-height: 1; } .m-h .x:hover { color: var(--red); }
@keyframes pop { from { transform: translateY(14px); opacity: 0;} to { transform: none; opacity: 1;} }
.drawer-mask { position: fixed; inset: 0; background: rgba(8,25,60,.3); z-index: 100; }
.drawer { position: fixed; right: 0; top: 0; bottom: 0; width: 480px; max-width: 94vw; background: #fff; z-index: 101; box-shadow: -12px 0 40px rgba(8,25,60,.2); display: flex; flex-direction: column; animation: slidein .2s ease; }
.drawer .d-h { padding: 14px 18px; border-bottom: 1px solid var(--line); font-weight: 700; display: flex; justify-content: space-between; }
.drawer .d-b { padding: 16px 18px; overflow-y: auto; flex: 1; }
@keyframes slidein { from { transform: translateX(40px); opacity: 0;} to { transform: none; opacity: 1;} }
#toast-root { position: fixed; top: 62px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #0f2c5e; color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 12.5px; box-shadow: var(--shadow); animation: slidein .2s; max-width: 360px; }
.toast.ok { background: var(--green); } .toast.err { background: var(--red); } .toast.warn { background: var(--orange); }

/* 智能体流水线 */
.pipeline { display: flex; align-items: stretch; gap: 0; overflow-x: auto; padding: 6px 2px; }
.pstep { min-width: 172px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; position: relative; flex-shrink: 0; }
.pstep .ps-no { font-size: 11px; color: var(--txt2); }
.pstep .ps-nm { font-weight: 700; font-size: 13.5px; margin: 2px 0 6px; }
.pstep .ps-st { font-size: 11.5px; }
.pstep.pending { opacity: .62; }
.pstep.running { border-color: var(--blue2); box-shadow: var(--glow); }
.pstep.running .ps-st { color: var(--blue); }
.pstep.done { border-color: #86efac; }
.pstep.edited { border-color: var(--orange); }
.pstep.human { border-style: dashed; border-color: var(--purple); }
.pstep .arrow { position: absolute; right: -15px; top: 50%; transform: translateY(-50%); color: #94a3b8; z-index: 2; font-size: 15px; }
.pstep .ps-tools { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.progress { height: 5px; background: var(--blue-l); border-radius: 3px; overflow: hidden; margin-top: 6px; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--blue2), #60a5fa); border-radius: 3px; transition: width .3s; }

/* 知识图谱 / SVG */
.svgbox { width: 100%; background: radial-gradient(1200px 500px at 50% -10%, var(--blue-xl), #fff 60%); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
svg text { user-select: none; }
.gnode { cursor: pointer; }
.gnode:hover circle { filter: brightness(1.12); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; padding: 8px 14px; font-size: 12px; color: var(--txt2); border-top: 1px dashed var(--line); }
.legend .li { display: flex; align-items: center; gap: 6px; }
.legend .dot { width: 10px; height: 10px; border-radius: 50%; }

/* 其他 */
.tabs { display: flex; gap: 2px; border-bottom: 2px solid var(--line); margin-bottom: 14px; }
.tabs .tab { padding: 8px 16px; cursor: pointer; font-size: 13.5px; color: var(--txt2); border-bottom: 2px solid transparent; margin-bottom: -2px; }
.tabs .tab:hover { color: var(--blue); }
.tabs .tab.active { color: var(--blue); border-bottom-color: var(--blue); font-weight: 700; }
.empty { text-align: center; color: var(--txt2); padding: 40px 0; font-size: 13px; }
.alert-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; background: #fff; }
.alert-item.y { border-left: 4px solid var(--orange); } .alert-item.r { border-left: 4px solid var(--red); }
.alert-item.g { border-left: 4px solid var(--green); }
.kv-row { display: flex; padding: 5px 0; border-bottom: 1px dashed #f1f5f9; font-size: 12.8px; }
.kv-row .k { width: 110px; color: var(--txt2); flex-shrink: 0; }
.kv-row .v { flex: 1; }
.log { font-family: "SF Mono", Consolas, monospace; font-size: 11.8px; background: #0b1f42; color: #9ecbff; border-radius: 8px; padding: 12px; max-height: 260px; overflow-y: auto; line-height: 1.7; }
.log .t { color: #4f6d9e; margin-right: 8px; }
.log .ok { color: #4ade80; } .log .warn { color: #fbbf24; } .log .err { color: #f87171; }
.switch { position: relative; width: 38px; height: 21px; background: #cbd5e1; border-radius: 20px; cursor: pointer; transition: .2s; flex-shrink: 0; }
.switch::after { content: ""; position: absolute; left: 2px; top: 2px; width: 17px; height: 17px; background: #fff; border-radius: 50%; transition: .2s; }
.switch.on { background: var(--blue); } .switch.on::after { left: 19px; }
.help { font-size: 11.5px; color: var(--txt2); line-height: 1.6; }
.divider { height: 1px; background: var(--line); margin: 12px 0; }
::-webkit-scrollbar { width: 9px; height: 9px; } ::-webkit-scrollbar-thumb { background: #c7d3e6; border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }

/* ============ 演示导览模式 ============ */
#demo-btn { border: 1px solid rgba(59,130,246,.5); background: linear-gradient(135deg, rgba(59,130,246,.14), rgba(99,102,241,.18));
  color: #bfe0ff; font-size: 12.5px; padding: 5px 12px; border-radius: 16px; cursor: pointer; letter-spacing: .5px; }
#demo-btn:hover { background: linear-gradient(135deg, rgba(59,130,246,.32), rgba(99,102,241,.36)); }
#demo-panel { position: fixed; right: 18px; bottom: 18px; width: 400px; z-index: 300;
  background: linear-gradient(160deg, #0f2148 0%, #152a5c 100%); color: #e8effc; border-radius: 14px;
  border: 1px solid rgba(96,148,255,.4); box-shadow: 0 12px 40px rgba(10,25,60,.5), 0 0 0 4px rgba(59,130,246,.08);
  font-size: 13px; animation: dmIn .3s ease; }
@keyframes dmIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
.dm-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  border-bottom: 1px solid rgba(120,160,255,.22); }
.dm-head b { font-size: 13.5px; letter-spacing: .5px; white-space: nowrap; }
.dm-dots { flex: 1; display: flex; gap: 4px; }
.dm-dots i { width: 12px; height: 5px; border-radius: 3px; background: rgba(140,170,230,.25); }
.dm-dots i.past { background: rgba(96,165,250,.55); }
.dm-dots i.cur { background: #60a5fa; box-shadow: 0 0 6px rgba(96,165,250,.8); }
.dm-close { cursor: pointer; color: #9db4dd; padding: 2px 6px; border-radius: 6px; }
.dm-close:hover { background: rgba(255,255,255,.1); color: #fff; }
.dm-title { padding: 10px 16px 2px; font-size: 14px; font-weight: 700; color: #bcd7ff; }
.dm-points { margin: 6px 16px 4px; padding-left: 16px; line-height: 1.75; color: #dbe7fb; }
.dm-points li { margin-bottom: 3px; }
.dm-tip { margin: 8px 16px; padding: 8px 10px; background: rgba(217,119,6,.16); border: 1px dashed rgba(251,191,36,.5);
  border-radius: 8px; color: #fde68a; font-size: 12.3px; line-height: 1.6; }
.dm-foot { display: flex; align-items: center; gap: 8px; padding: 10px 14px 12px; }
.dm-foot .btn { padding: 5px 14px; font-size: 12.5px; background: rgba(255,255,255,.08); border-color: rgba(140,170,230,.35); color: #dbe7fb; }
.dm-foot .btn:hover { background: rgba(255,255,255,.16); }
.dm-foot .btn.primary { background: linear-gradient(135deg, #2563eb, #4f7df9); border: none; color: #fff; }
.dm-foot .btn:disabled { opacity: .4; cursor: not-allowed; }
.dm-reset { margin-right: auto; color: #93c5fd; font-size: 12px; cursor: pointer; text-decoration: underline dotted; }
.dm-done { padding: 26px 16px; text-align: center; font-size: 17px; font-weight: 700; color: #bcd7ff; line-height: 1.9; }
.dm-done span { font-size: 12.5px; font-weight: 400; color: #9db4dd; }
