/* =========================================================================
 * demo.css  —  基因分析智能体 · 控制台（自包含）
 * 设计语言参考用户提供的 app.css：明亮、专业、SaaS 控制台
 * 全原生 canvas 绘图（不依赖 Chart.js），固定高度容器，杜绝无限增高 bug
 * ========================================================================= */

:root {
  --brand:#2563eb; --brand-600:#1d4ed8; --brand-soft:#eaf1ff; --brand-ring:rgba(37,99,235,.16);
  --accent:#06b6d4;
  --bg-page:#f5f8fd; --bg-surface:#ffffff; --bg-subtle:#f1f5fb; --bg-hover:#eef3fb;
  --border-soft:#eef1f6; --border-default:#e3e8f0; --border-strong:#cbd5e1;
  --text-primary:#0f1b2d; --text-secondary:#46566c; --text-tertiary:#8a94a6;
  --success:#15803d; --warning:#b45309; --danger:#be123c;
  --r-sm:8px; --r-md:10px; --r-lg:14px; --r-xl:20px; --r-full:999px;
  --shadow-sm:0 1px 2px rgba(16,24,40,.05),0 1px 3px rgba(16,24,40,.04);
  --shadow-md:0 6px 18px rgba(16,24,40,.08);
  --shadow-lg:0 20px 44px -14px rgba(16,24,40,.22);
  --font-ui:"Noto Sans SC","Sora",system-ui,-apple-system,sans-serif;
  --font-mono:"JetBrains Mono",ui-monospace,Menlo,monospace;
}

* { box-sizing:border-box; margin:0; padding:0; }
html,body { height:100%; }
body.app {
  font-family:var(--font-ui); background:var(--bg-page); color:var(--text-primary);
  -webkit-font-smoothing:antialiased; line-height:1.55;
}
a { color:inherit; text-decoration:none; }
button { font-family:inherit; cursor:pointer; }
code { font-family:var(--font-mono); }
::-webkit-scrollbar { width:9px; height:9px; }
::-webkit-scrollbar-thumb { background:#d6dae4; border-radius:999px; }
::-webkit-scrollbar-thumb:hover { background:#c2c8d4; }

/* 页面进入过渡 */
.page-fade { animation:pageIn .55s cubic-bezier(.2,.7,.2,1) both; }
@keyframes pageIn { from{opacity:0; filter:blur(10px); transform:translateY(8px)} to{opacity:1; filter:blur(0); transform:none} }
body.leaving { animation:pageOut .4s ease forwards; }
@keyframes pageOut { to{opacity:0; filter:blur(12px)} }

/* ---------- 通用按钮 / 标签 ---------- */
.btn { display:inline-flex; align-items:center; gap:8px; justify-content:center; padding:10px 18px;
  border:none; border-radius:var(--r-md); background:var(--brand); color:#fff; font-weight:600; font-size:14px;
  transition:transform .12s, box-shadow .2s, background .2s; box-shadow:0 6px 16px -8px var(--brand); }
.btn:hover { transform:translateY(-1px); background:var(--brand-600); }
.btn .ic { width:16px; height:16px; }
.btn.ghost { background:var(--bg-surface); color:var(--text-secondary); border:1px solid var(--border-default); box-shadow:none; }
.btn.ghost:hover { background:var(--bg-hover); color:var(--text-primary); }
.btn.sm { padding:7px 13px; font-size:13px; }
.tag { display:inline-flex; align-items:center; padding:3px 10px; border-radius:var(--r-full); font-size:12px; font-weight:600; background:var(--brand-soft); color:var(--brand-600); }
.muted { color:var(--text-tertiary); }
.pill { padding:3px 10px; border-radius:var(--r-full); font-size:12px; font-weight:600; display:inline-flex; align-items:center; gap:6px; }
.pill .led { width:6px; height:6px; border-radius:50%; }
.pill.info { background:#e8f0fe; color:#1d4ed8; } .pill.info .led{background:#1d4ed8}
.pill.warning { background:#fdf2e3; color:#b45309; } .pill.warning .led{background:#b45309}
.pill.danger { background:#fdeaea; color:#be123c; } .pill.danger .led{background:#be123c}
.pill.success { background:#e7f6ec; color:#15803d; } .pill.success .led{background:#15803d}
.pill.run { background:#e8f0fe; color:#1d4ed8; } .pill.run .led{background:#1d4ed8; animation:blink 1s infinite}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.35} }

/* ---------- 布局 ---------- */
.app-layout { display:flex; min-height:100vh; }
.sidebar { width:236px; flex:none; background:var(--bg-surface); border-right:1px solid var(--border-soft);
  padding:18px 14px; display:flex; flex-direction:column; gap:4px; position:sticky; top:0; height:100vh; overflow-y:auto; }
.sb-brand { display:flex; align-items:center; gap:11px; padding:6px 8px 16px; }
.sb-brand img { width:38px; height:38px; }
.sb-brand .nm { font-weight:800; font-size:15px; letter-spacing:.2px; }
.sb-brand .sub { font-size:11px; color:var(--text-tertiary); font-family:var(--font-mono); letter-spacing:1px; }
.sb-section { font-size:11px; font-weight:700; color:var(--text-tertiary); padding:14px 12px 6px; letter-spacing:.05em; }
.nav-item { display:flex; align-items:center; gap:11px; padding:10px 12px; border-radius:var(--r-md);
  color:var(--text-secondary); font-size:14px; font-weight:500; transition:background .15s,color .15s; cursor:pointer; }
.nav-item i { width:18px; height:18px; opacity:.85; }
.nav-item:hover { background:var(--bg-hover); color:var(--text-primary); }
.nav-item.active { background:var(--brand-soft); color:var(--brand-600); font-weight:700; }
.sb-foot { margin-top:auto; padding:12px 10px; font-size:12px; color:var(--text-tertiary); border-top:1px solid var(--border-soft); }
.sb-foot b { color:var(--brand-600); }

.main-area { flex:1; min-width:0; display:flex; flex-direction:column; }
.topbar { display:flex; align-items:center; justify-content:space-between; padding:14px 28px;
  border-bottom:1px solid var(--border-soft); background:rgba(255,255,255,.82); backdrop-filter:blur(8px); position:sticky; top:0; z-index:6; }
.topbar .t-title { font-weight:700; font-size:16px; }
.topbar .t-right { display:flex; align-items:center; gap:12px; }
.page { padding:24px 28px 64px; }
.page-head { margin-bottom:20px; }
.page-head h2 { font-size:20px; font-weight:800; }
.page-head p { color:var(--text-tertiary); font-size:14px; margin-top:3px; }
.module { animation:pageIn .4s cubic-bezier(.2,.7,.2,1) both; }

/* ---------- metric 卡 ---------- */
.metrics { display:grid; grid-template-columns:repeat(4,1fr); gap:16px; margin-bottom:22px; }
.metric { background:var(--bg-surface); border:1px solid var(--border-soft); border-radius:var(--r-lg); padding:18px 20px; box-shadow:var(--shadow-sm); }
.metric .lbl { font-size:13px; color:var(--text-tertiary); display:flex; align-items:center; gap:7px; }
.metric .lbl i { width:15px; height:15px; }
.metric .val { font-size:28px; font-weight:800; margin-top:8px; letter-spacing:-.02em; }
.metric .val .u { font-size:14px; font-weight:600; color:var(--text-tertiary); margin-left:3px; }
.metric .trend { margin-top:6px; font-size:12px; font-weight:600; color:var(--success); }

/* ---------- 面板 / 网格 ---------- */
.panel { background:var(--bg-surface); border:1px solid var(--border-soft); border-radius:var(--r-lg); padding:20px; box-shadow:var(--shadow-sm); }
.panel + .panel { margin-top:16px; }
.panel-h { display:flex; align-items:center; justify-content:space-between; margin-bottom:14px; }
.panel-h h3 { font-size:15px; font-weight:700; }
.panel-h .hint { font-size:12px; color:var(--text-tertiary); font-family:var(--font-mono); }
.cards-2 { display:grid; grid-template-columns:1fr 1fr; gap:16px; }
.cards-3 { display:grid; grid-template-columns:repeat(3,1fr); gap:16px; }

/* ---------- 表格 ---------- */
table.tbl { width:100%; border-collapse:collapse; font-size:14px; }
table.tbl th { text-align:left; padding:11px 14px; font-size:12px; font-weight:700; color:var(--text-tertiary);
  letter-spacing:.03em; border-bottom:1px solid var(--border-default); }
table.tbl td { padding:12px 14px; border-bottom:1px solid var(--border-soft); color:var(--text-secondary); }
table.tbl tr:hover td { background:var(--bg-hover); }
.bar { height:7px; background:var(--bg-subtle); border-radius:999px; overflow:hidden; min-width:90px; }
.bar > i { display:block; height:100%; background:linear-gradient(90deg,var(--brand),var(--accent)); border-radius:999px; }

/* ---------- 图表容器（固定高度，杜绝无限增高） ---------- */
.chart-box { position:relative; width:100%; }
canvas.viz { display:block; width:100%; }

/* heatmap */
.heat { display:grid; gap:3px; }
.heat .cell { aspect-ratio:1; border-radius:4px; }
.heat-lab { font-size:10.5px; font-family:var(--font-mono); color:var(--text-tertiary); display:flex; align-items:center; }
.legend { display:flex; gap:14px; flex-wrap:wrap; margin-top:12px; }
.legend .li { display:flex; align-items:center; gap:7px; font-size:12.5px; color:var(--text-secondary); }
.legend .sw { width:11px; height:11px; border-radius:3px; }

/* ---------- 工作流（纵向流水线 + 产出预览） ---------- */
.wf-toolbar { display:flex; gap:10px; align-items:center; margin-bottom:18px; flex-wrap:wrap; }
.flow-run { display:flex; flex-direction:column; }
.flow-step { display:flex; gap:14px; }
.flow-step .rail { display:flex; flex-direction:column; align-items:center; }
.flow-step .node { width:34px; height:34px; border-radius:50%; background:var(--brand-soft); color:var(--brand-600);
  display:grid; place-items:center; font-weight:700; font-size:13px; border:2px solid var(--brand); flex:none; transition:.25s; }
.flow-step .line { width:2px; flex:1; background:var(--border-default); min-height:14px; }
.flow-step .body { padding-bottom:16px; flex:1; }
.fs-card { background:var(--bg-surface); border:1px solid var(--border-soft); border-radius:var(--r-md);
  padding:13px 15px; box-shadow:var(--shadow-sm); cursor:pointer; transition:.18s; }
.fs-card:hover { box-shadow:var(--shadow-md); border-color:var(--brand-ring); transform:translateY(-1px); }
.fs-card.sel { border-color:var(--brand); box-shadow:0 0 0 3px var(--brand-ring); }
.fs-top { display:flex; align-items:center; justify-content:space-between; }
.fs-ti { font-weight:700; font-size:14px; }
.fs-tool { font-size:11px; color:var(--text-tertiary); font-family:var(--font-mono); }
.fs-io { margin-top:8px; font-size:12px; color:var(--text-secondary); display:flex; gap:18px; flex-wrap:wrap; font-family:var(--font-mono); }
.fs-io b { color:var(--brand-600); font-weight:600; }
.flow-step.done .node { background:var(--brand); color:#fff; }
.flow-step.running .node { background:#fff; color:var(--brand); border-color:var(--brand); animation:ring 1.2s infinite; }
@keyframes ring { 0%{box-shadow:0 0 0 0 var(--brand-ring)} 70%{box-shadow:0 0 0 8px transparent} 100%{box-shadow:0 0 0 0 transparent} }
.flow-step.pending .node { background:var(--bg-subtle); color:var(--text-tertiary); border-color:var(--border-default); }
.flow-step.pending .fs-card { opacity:.78; }

/* 产出预览区 */
.out-view { margin-top:18px; }
.out-empty { text-align:center; padding:38px; color:var(--text-tertiary); font-size:14px; }
.out-head { display:flex; align-items:center; justify-content:space-between; margin-bottom:14px; }
.out-head h3 { font-size:15px; font-weight:700; }
.out-pre { background:#0c1424; color:#cfe3ff; font-family:var(--font-mono); font-size:12.5px; line-height:1.7;
  border-radius:var(--r-md); padding:14px 16px; max-height:320px; overflow:auto; white-space:pre; }
.out-pre .c { color:#5c6f93; } .out-pre .ok{color:#5fe3a6} .out-pre .wn{color:#ffcf6b}
.qc-report { border:1px solid var(--border-default); border-radius:var(--r-md); overflow:hidden; }
.qc-report .qr-row { display:flex; align-items:center; justify-content:space-between; padding:11px 15px; border-bottom:1px solid var(--border-soft); font-size:13.5px; }
.qc-report .qr-row:last-child { border-bottom:none; }
.ai-doc { background:var(--bg-subtle); border:1px solid var(--border-soft); border-radius:var(--r-md); padding:18px 20px; font-size:14px; line-height:1.85; white-space:pre-wrap; color:var(--text-primary); }

/* AI 思考动画 */
.ai-think { display:flex; align-items:center; gap:10px; color:var(--brand-600); font-size:13px; font-family:var(--font-mono); padding:8px 0; }
.spin { width:16px; height:16px; border:2px solid var(--brand-ring); border-top-color:var(--brand); border-radius:50%; animation:rot .8s linear infinite; }
@keyframes rot { to{transform:rotate(360deg)} }

/* ---------- 智能助手页面（整页对话） ---------- */
.chat-wrap { display:flex; flex-direction:column; height:calc(100vh - 168px); background:var(--bg-surface);
  border:1px solid var(--border-soft); border-radius:var(--r-lg); box-shadow:var(--shadow-sm); overflow:hidden; }
.chat-head { padding:14px 20px; border-bottom:1px solid var(--border-soft); display:flex; align-items:center; gap:12px; }
.chat-head .pa { width:40px; height:40px; border-radius:11px; background:linear-gradient(135deg,var(--brand),var(--accent));
  color:#fff; display:grid; place-items:center; }
.chat-head .pa i { width:20px; height:20px; }
.chat-head h3 { font-size:15px; font-weight:700; }
.chat-head .st { font-size:12px; color:var(--success); display:flex; align-items:center; gap:6px; }
.chat-head .st .led { width:6px; height:6px; border-radius:50%; background:var(--success); }
.chat-body { flex:1; overflow-y:auto; padding:22px; display:flex; flex-direction:column; gap:16px; }
.msg { max-width:74%; }
.msg.user { align-self:flex-end; }
.msg .bubble { padding:12px 15px; border-radius:14px; font-size:14px; line-height:1.7; white-space:pre-wrap; }
.msg.user .bubble { background:var(--brand); color:#fff; border-bottom-right-radius:4px; }
.msg.ai .bubble { background:var(--bg-subtle); color:var(--text-primary); border-bottom-left-radius:4px; }
.typing { display:inline-flex; gap:4px; }
.typing span { width:7px; height:7px; border-radius:50%; background:var(--brand); opacity:.5; animation:bounce 1.2s infinite; }
.typing span:nth-child(2){animation-delay:.2s} .typing span:nth-child(3){animation-delay:.4s}
@keyframes bounce { 0%,100%{opacity:.3; transform:translateY(0)} 50%{opacity:1; transform:translateY(-3px)} }
.suggest { padding:0 20px 14px; display:flex; gap:8px; flex-wrap:wrap; }
.suggest button { background:var(--bg-subtle); border:1px solid var(--border-soft); border-radius:var(--r-full);
  padding:7px 14px; font-size:12.5px; color:var(--text-secondary); display:flex; align-items:center; gap:6px; }
.suggest button i { width:14px; height:14px; color:var(--brand); }
.suggest button:hover { background:var(--brand-soft); color:var(--brand-600); }
.chat-input { border-top:1px solid var(--border-soft); padding:14px; display:flex; gap:10px; }
.chat-input input { flex:1; padding:12px 15px; border:1px solid var(--border-default); border-radius:var(--r-md); font-size:14px; outline:none; font-family:inherit; }
.chat-input input:focus { border-color:var(--brand); box-shadow:0 0 0 3px var(--brand-ring); }
.chat-input .send { width:46px; border:none; border-radius:var(--r-md); background:var(--brand); color:#fff; display:grid; place-items:center; }
.chat-input .send:hover { background:var(--brand-600); }
.chat-input .send i { width:18px; height:18px; }

/* ---------- 大屏（计算集群可视化） ---------- */
.screen { background:#0a0f1f; border-radius:var(--r-lg); padding:22px; color:#cdd6e8; }
.screen .sc-head { display:flex; align-items:center; justify-content:space-between; margin-bottom:18px; }
.screen .sc-head h2 { color:#fff; font-size:18px; }
.screen .sc-head .live { display:flex; align-items:center; gap:7px; font-size:13px; color:#6ee7b7; }
.screen .sc-head .live .dot { width:8px; height:8px; border-radius:50%; background:#34d399; animation:blink 1.4s infinite; }
.sc-metrics { display:grid; grid-template-columns:repeat(3,1fr); gap:14px; margin-bottom:18px; }
.sc-metric { background:rgba(255,255,255,.04); border:1px solid rgba(255,255,255,.08); border-radius:var(--r-md); padding:14px 16px; }
.sc-metric .v { font-size:24px; font-weight:800; color:#fff; }
.sc-metric .l { font-size:12px; color:#93a4c7; margin-top:4px; }
.bar-row { display:flex; align-items:center; gap:10px; margin-bottom:11px; font-size:13px; }
.bar-row .bn { width:120px; color:#b9c4dd; flex:none; font-family:var(--font-mono); font-size:12px; }
.bar-row .bt { flex:1; height:10px; background:rgba(255,255,255,.08); border-radius:999px; overflow:hidden; }
.bar-row .bt span { display:block; height:100%; background:linear-gradient(90deg,#38bdf8,#22d3ee); border-radius:999px; transition:width .6s; }
.bar-row .bv { width:46px; text-align:right; color:#e2e8f5; }

/* ---------- toast / modal ---------- */
.toast { position:fixed; bottom:24px; left:50%; transform:translateX(-50%); background:#0d1426; color:#fff;
  padding:11px 20px; border-radius:var(--r-md); font-size:14px; box-shadow:var(--shadow-lg); z-index:999; opacity:0; transition:opacity .2s,transform .2s; pointer-events:none; }
.toast.show { opacity:1; transform:translateX(-50%) translateY(-4px); }

/* ---------- 响应式 ---------- */
@media (max-width:960px) {
  .metrics { grid-template-columns:repeat(2,1fr); }
  .cards-2,.cards-3,.sc-metrics { grid-template-columns:1fr; }
  .sidebar { width:64px; }
  .sb-brand .nm,.sb-brand .sub,.nav-item span,.sb-foot,.sb-section { display:none; }
  .nav-item { justify-content:center; }
}
