/* BINAgent 完整前端样式 */
:root {
  --bg: #f1f5f9; --panel: #ffffff; --line: #e2e8f0;
  --ink: #1e293b; --muted: #64748b;
  --accent: #2563eb; --accent-soft: #dbeafe;
  --ok: #16a34a; --ok-soft: #dcfce7;
  --warn: #d97706; --warn-soft: #fef3c7;
  --bad: #dc2626; --bad-soft: #fee2e2;
  --dark: #0f172a;
  --radius: 10px;
  --mono: "Cascadia Code", Consolas, monospace;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font: 14px/1.6 "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
       background: var(--bg); color: var(--ink); }
.shell { display: flex; min-height: 100vh; }

/* ---- 侧栏 ---- */
.sidebar { width: 220px; background: var(--dark); color: #cbd5e1;
           display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { padding: 20px 18px 14px; border-bottom: 1px solid #1e293b; }
.brand-name { font-size: 20px; font-weight: 700; color: #fff; letter-spacing: .5px; }
.brand-sub { font-size: 12px; color: #94a3b8; margin-top: 2px; }
.nav { flex: 1; padding: 12px 8px; }
.nav a { display: block; padding: 9px 14px; margin: 2px 0; border-radius: 8px;
         color: #cbd5e1; text-decoration: none; font-size: 14px; }
.nav a:hover { background: #1e293b; color: #fff; }
.nav a.active { background: var(--accent); color: #fff; }
.side-status { padding: 12px 16px; font-size: 12px; color: #94a3b8;
               border-top: 1px solid #1e293b; }

/* ---- 主区 ---- */
.content { flex: 1; min-width: 0; padding: 0 22px 40px; }
.topbar { display: flex; align-items: center; justify-content: space-between;
          padding: 16px 0 14px; border-bottom: 1px solid var(--line); margin-bottom: 18px;
          position: sticky; top: 0; background: var(--bg); z-index: 5; }
.topbar-title { font-size: 18px; font-weight: 600; }
.topbar-right { display: flex; gap: 8px; align-items: center; }
.pill { font-size: 12px; padding: 3px 10px; border-radius: 999px;
        background: #e2e8f0; color: #475569; white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: #166534; }
.pill.warn { background: var(--warn-soft); color: #92400e; }
.pill.stage { background: var(--accent-soft); color: #1e40af; }

/* ---- 通用组件 ---- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
        padding: 16px 18px; margin-bottom: 14px; }
.card h3 { font-size: 14px; margin-bottom: 10px; color: var(--dark);
           border-left: 3px solid var(--accent); padding-left: 8px; }
.btn { background: var(--accent); color: #fff; border: 0; border-radius: 8px;
       padding: 8px 18px; font-size: 14px; cursor: pointer; }
.btn:disabled { background: #94a3b8; cursor: wait; opacity: .7; }
.btn.ghost { background: #fff; color: var(--accent); border: 1px solid var(--accent); }
.btn.danger { background: #fff; color: var(--bad); border: 1px solid var(--bad); }
.btn.sm { padding: 4px 12px; font-size: 13px; }
select, input[type=text] { padding: 6px 10px; border: 1px solid var(--line);
        border-radius: 8px; font-size: 14px; background: #fff; color: var(--ink); }
.muted { color: var(--muted); font-size: 12px; }
.mono { font-family: var(--mono); font-size: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 6px 9px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; background: #f8fafc; white-space: nowrap; }
tr:hover td { background: #f8fafc; }
.tag { font-size: 11px; padding: 1px 9px; border-radius: 999px; white-space: nowrap; }
.tag.pos { background: var(--ok-soft); color: #166534; }
.tag.neg { background: var(--bad-soft); color: #991b1b; }
.tag.mod { background: #e0e7ff; color: #3730a3; }
.tag.ok { background: var(--ok-soft); color: #166534; }
.tag.warn { background: var(--warn-soft); color: #92400e; }
.tag.bad { background: var(--bad-soft); color: #991b1b; }
.tag.dim { background: #e2e8f0; color: #475569; }
.grid { display: grid; gap: 12px; }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1000px) { .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr 1fr; } }
.stat { background: #f1f5f9; border-radius: 8px; padding: 10px 12px; }
.stat b { display: block; font-size: 20px; color: var(--accent); }
.stat span { font-size: 12px; color: var(--muted); }
.list { padding-left: 20px; }
.list li { margin: 4px 0; }
.warn-item { background: var(--warn-soft); border: 1px solid #fde68a; border-radius: 8px;
             padding: 8px 12px; margin: 6px 0; font-size: 13px; }
pre.dump { background: var(--dark); color: #a5f3fc; padding: 12px; border-radius: 8px;
           overflow: auto; font-size: 12px; max-height: 400px; }
details summary { cursor: pointer; color: var(--muted); font-size: 12px; }
.empty { color: var(--muted); font-size: 13px; padding: 12px 0; text-align: center; }

/* ---- 专家消息分段（思考 / 工具 / 正文）---- */
.sec { margin: 3px 0; }
.sec-head { display: flex; align-items: center; gap: 7px; cursor: pointer;
            color: #475569; font-size: 12.5px; padding: 5px 10px; user-select: none;
            border-radius: 7px; background: #f1f5f9; width: fit-content; }
.sec-head:hover { background: var(--accent-soft); color: #1e40af; }
.sec-head b { font-weight: 600; }
.chev { width: 0; height: 0; border-left: 5px solid #94a3b8;
        border-top: 4px solid transparent; border-bottom: 4px solid transparent;
        transition: transform .15s; flex-shrink: 0; }
.sec.open .chev { transform: rotate(90deg); }
.sec-sum { color: #94a3b8; font-size: 12px; overflow: hidden; text-overflow: ellipsis;
           white-space: nowrap; max-width: 420px; }
.sec-detail { display: none; background: #f8fafc; border: 1px solid var(--line);
              border-radius: 8px; padding: 10px 12px; margin: 6px 0 10px;
              font-size: 12px; font-family: var(--mono); white-space: pre-wrap;
              max-height: 280px; overflow: auto; }
.sec.open .sec-detail { display: block; }
.msg-body { font-size: 14px; line-height: 1.75; color: var(--ink);
            padding: 2px 2px 6px; }
.msg-user { display: inline-block; max-width: 75%; text-align: left;
            background: var(--accent-soft); border: 1px solid #bfdbfe;
            border-radius: 14px 14px 4px 14px; padding: 10px 14px; font-size: 14px; }
.msg-user p { margin: 0; }
/* Markdown 内容样式 */
.msg-body h4, .msg-body h5, .msg-body h6 { margin: 10px 0 4px; color: var(--dark); }
.msg-body p { margin: 4px 0; }
.msg-body ul, .msg-body ol { padding-left: 22px; margin: 4px 0; }
.msg-body li { margin: 2px 0; }
.msg-body code { background: #eef2f7; padding: 1px 5px; border-radius: 4px;
                 font-size: 12px; font-family: var(--mono); }
.msg-body pre.md-code { background: var(--dark); color: #a5f3fc; padding: 10px 12px;
                        border-radius: 8px; overflow: auto; font-size: 12px;
                        margin: 6px 0; font-family: var(--mono); line-height: 1.5; }
.msg-body pre.md-code code { background: transparent; padding: 0; color: inherit; }
.msg-body a { color: var(--accent); }
.msg-body blockquote { border-left: 3px solid var(--line); padding-left: 10px;
                       color: var(--muted); margin: 6px 0; }

/* ---- 全高聊天布局 ---- */
.chat-shell { display: flex; flex-direction: column;
              height: calc(100vh - 215px); min-height: 420px; }
.chat-history { flex: 1; overflow-y: auto; border: 1px solid var(--line);
                border-radius: 8px; padding: 12px 14px; margin: 10px 0;
                background: #f8fafc; }
.chat-input { flex-shrink: 0; display: flex; gap: 8px; }

/* ---- 概览 stepper ---- */
.stepper { display: flex; flex-wrap: wrap; gap: 6px; }
.step-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px;
             border-radius: 999px; font-size: 12px; border: 1px solid var(--line);
             background: #fff; color: var(--muted); }
.step-chip .idx { font-weight: 700; color: var(--accent); }
.step-chip.done { background: var(--ok-soft); border-color: #86efac; color: #166534; }
.step-chip.current { background: var(--accent-soft); border-color: #93c5fd; color: #1e40af; font-weight: 600; }

/* ---- 流水线步骤卡 ---- */
.step-card { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px;
             overflow: hidden; }
.step-head { display: flex; align-items: center; gap: 10px; padding: 11px 14px; cursor: pointer;
             background: #fff; }
.step-head:hover { background: #f8fafc; }
.step-head .no { width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center;
                 justify-content: center; font-weight: 700; font-size: 13px; background: #e2e8f0; color: #475569; }
.step-card.done .step-head .no { background: var(--ok); color: #fff; }
.step-card.current .step-head .no { background: var(--accent); color: #fff; }
.step-card.done .step-head { background: #f0fdf4; }
.step-card.current .step-head { background: #eff6ff; }
.step-card.fail { border-color: #fca5a5; }
.step-card.fail .step-head { background: #fef2f2; }
.step-card.fail .step-head .no { background: var(--bad); color: #fff; }
.fail-box { background: #fef2f2; border-top: 1px solid #fecaca; color: #b91c1c;
            padding: 10px 16px; font-family: var(--mono, monospace); font-size: 12px;
            word-break: break-all; }
.approve-card { border: 1px solid #fcd34d; background: #fffbeb; }
.approve-card h3 { color: #92400e; }

/* ---- 下一步引导卡 ---- */
.guide-card h3 { margin-bottom: 8px; }
.guide-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px;
              border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px;
              background: #fff; text-decoration: none; color: inherit; }
.guide-item:hover { border-color: var(--accent); background: #f0f7ff; }
.guide-item .guide-icon { font-size: 16px; }
.guide-item .guide-text { flex: 1; }
.guide-item .btn { pointer-events: none; }
.step-body { padding: 12px 16px; border-top: 1px solid var(--line); background: #fff; }

/* ---- 假设卡 ---- */
.hypo-card { border: 1px solid var(--line); border-left: 4px solid var(--accent);
             border-radius: 8px; padding: 12px 14px; margin-bottom: 10px; background: #fff; }
.hypo-card .rank { font-weight: 700; color: var(--accent); }
.hypo-bar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; margin-top: 8px; }
.hypo-bar .sup { background: var(--ok); }
.hypo-bar .agt { background: var(--bad); }
.hypo-bar .mis { background: #94a3b8; }

/* ---- toast ---- */
.toast { position: fixed; right: 20px; bottom: 20px; background: var(--dark); color: #fff;
         padding: 10px 18px; border-radius: 8px; font-size: 13px; opacity: 0;
         transition: opacity .25s; pointer-events: none; max-width: 420px; z-index: 99; }
.toast.show { opacity: 1; }
.toast.err { background: #7f1d1d; }

/* ---- 确认对话框 ---- */
.modal-mask { position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
              display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal { background: #fff; border-radius: 12px; padding: 20px 22px; max-width: 420px;
         width: calc(100% - 48px); box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal h3 { margin-bottom: 8px; }
.modal .btn.danger { background: var(--bad); color: #fff; }

/* ---- loading ---- */
.spin { display: inline-block; width: 13px; height: 13px; border: 2px solid #bfdbfe;
        border-top-color: var(--accent); border-radius: 50%;
        animation: sp .8s linear infinite; vertical-align: -2px; }
@keyframes sp { to { transform: rotate(360deg); } }

/* 证据图：左 card + 右侧独立详情栏（平级，等高） */
.graph-layout { display: flex; gap: 12px; align-items: stretch; }
.graph-main { flex: 1; min-width: 0; }
.graph-right { width: 320px; flex: 0 0 320px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; padding: 14px; overflow-y: auto;
  font-size: 13px; }
.graph-right h3 { font-size: 14px; margin: 0 0 8px; }
.graph-right h4 { font-size: 13px; margin: 10px 0 4px; }
.graph-right table { font-size: 12px; }
.graph-right .list { font-size: 12px; }

/* ---- 专家组织动态（主任窗口） ---- */
.org-timeline { border: 1px solid var(--line); border-radius: 8px;
                background: #f8fafc; margin-bottom: 10px; padding: 8px 12px;
                max-height: 220px; overflow-y: auto; }
.org-head { font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.org-item { display: flex; gap: 8px; align-items: baseline; padding: 3px 0;
            font-size: 12.5px; border-bottom: 1px dashed #e2e8f0; }
.org-item:last-child { border-bottom: none; }
.org-item.working .org-text { color: #b45309; font-weight: 600; }
.org-item.done .org-text { color: #166534; }
.org-item .org-text { flex: 1; }

/* ---- 专家状态点 / 工作中热点（CSS 圆点，不用 emoji） ---- */
.exp-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%;
           background: #cbd5e1; margin-right: 5px; vertical-align: 1px; }
.exp-dot.busy { background: #f59e0b; animation: pulse 1.1s ease-in-out infinite; }
.exp-dot.done { background: #22c55e; }
.step-chip.busy { border-color: #f59e0b; background: #fffbeb;
                  box-shadow: 0 0 0 2px rgba(245, 158, 11, .18); }
.step-chip.done { border-color: #22c55e; background: #f0fdf4; }
@keyframes pulse { 50% { opacity: .35; } }

/* ---- 组织动态事件标签 ---- */
.org-tag { font-size: 11px; color: #475569; background: #e2e8f0;
           border-radius: 4px; padding: 1px 6px; flex-shrink: 0; }
.org-item.working .org-tag { background: #fef3c7; color: #b45309; }
.org-item.done .org-tag { background: #dcfce7; color: #166534; }
.org-item.stage .org-tag { background: #e0f2fe; color: #0369a1; }
.org-item.organize .org-tag { background: #ede9fe; color: #5b21b6; }

/* ---- 危险操作按钮 ---- */
.danger-text { color: var(--bad) !important; }
.danger-text:hover { background: #fef2f2; }

/* ---- 文档页 ---- */
.docs-layout { display: flex; gap: 12px; align-items: flex-start; }
.docs-nav { width: 250px; flex: 0 0 250px; position: sticky; top: 12px;
            max-height: calc(100vh - 150px); overflow-y: auto; }
.docs-link { display: block; padding: 6px 10px; margin-bottom: 2px;
             border-radius: 6px; font-size: 13px; color: var(--ink);
             text-decoration: none; }
.docs-link:hover { background: var(--accent-soft); }
.docs-link.active { background: var(--accent); color: #fff; }
.docs-content { flex: 1; min-width: 0; }
.docs-content .msg-body { font-size: 14px; }
.docs-content .msg-body h1 { font-size: 22px; border-bottom: 2px solid var(--line);
                             padding-bottom: 6px; margin: 4px 0 12px; }
.docs-content .msg-body h2 { font-size: 18px; margin: 22px 0 8px; color: var(--dark); }
.docs-content .msg-body h3 { font-size: 15px; margin: 16px 0 6px; }
.docs-content .msg-body blockquote { border-left: 3px solid var(--accent);
  background: #f0f7ff; padding: 6px 12px; margin: 8px 0; border-radius: 0 6px 6px 0; }
.doc-table { border-collapse: collapse; margin: 10px 0; font-size: 13px; width: 100%; }
.doc-table th, .doc-table td { border: 1px solid var(--line); padding: 5px 10px;
                               text-align: left; vertical-align: top; }
.doc-table th { background: #f1f5f9; font-weight: 600; }
.doc-table tr:nth-child(even) td { background: #fafbfc; }
