/* ═══════════════════════════════════════════════════════════
   智核 WorkMind 企业级 AI 智能工作平台 — 设计系统
   深空蓝紫 × 光感渐变，企业级 AI 品牌视觉
   ═══════════════════════════════════════════════════════════ */
:root {
  --brand: #5046e5;
  --brand-2: #7c3aed;
  --brand-grad: linear-gradient(135deg, #5046e5 0%, #7c3aed 100%);
  --brand-soft: #eef0fe;
  --ink: #16192c;
  --ink-2: #4b4f66;
  --ink-3: #8a8fa8;
  --line: #e6e8f2;
  --bg: #f5f6fb;
  --card: #ffffff;
  --side: #14162b;
  --side-2: #1c1f3a;
  --ok: #0e9f6e;
  --warn: #dd9a00;
  --err: #e02424;
  --run: #2563eb;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(22,25,44,.04), 0 8px 24px -12px rgba(22,25,44,.12);
  font-size: 14px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
a { color: inherit; text-decoration: none; }

/* ── 品牌与通用 ──────────────────────────── */
.brand-logo {
  color: #fff; background: var(--brand-grad); border-radius: 12px;
  display: flex; align-items: center; justify-content: center; flex: none;
}
.brand-logo.big { width: 64px; height: 64px; border-radius: 18px; box-shadow: 0 12px 32px -8px rgba(80,70,229,.55); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 10px; padding: 9px 16px; font-size: 14px; cursor: pointer;
  transition: .15s all; font-family: inherit; line-height: 1;
}
.btn:hover { border-color: #cbcdde; background: #fafafe; }
.btn.primary { background: var(--brand-grad); color: #fff; border: none; box-shadow: 0 6px 16px -6px rgba(80,70,229,.5); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; border-color: rgba(255,255,255,.2); color: #cfd2e6; }
.btn.ghost:hover { background: rgba(255,255,255,.06); }
.btn.sm { padding: 6px 12px; font-size: 12.5px; border-radius: 8px; }
.btn.danger { color: var(--err); border-color: #f5c6c6; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.tag {
  display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; background: var(--brand-soft); color: var(--brand); font-weight: 500;
}
.tag.ok { background: #e6f6ef; color: var(--ok); }
.tag.err { background: #fdeaea; color: var(--err); }
.tag.warn { background: #fdf4dd; color: var(--warn); }
.tag.run { background: #e8effd; color: var(--run); }
.tag.gray { background: #eef0f5; color: var(--ink-3); }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card .card-hd {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px 0 20px;
}
.card .card-hd h3 { font-size: 15.5px; font-weight: 600; }
.card .card-bd { padding: 16px 20px 20px; }

input, select, textarea {
  font-family: inherit; font-size: 14px; color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px;
  background: #fff; outline: none; transition: .15s; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(80,70,229,.12); }
label { font-size: 13px; color: var(--ink-2); font-weight: 500; display: block; margin: 4px 0; }

/* ── 布局骨架 ──────────────────────────── */
.shell { display: flex; height: 100vh; overflow: hidden; }
.sidebar {
  width: 232px; flex: none; background: linear-gradient(180deg, var(--side) 0%, var(--side-2) 100%);
  color: #cfd2e6; display: flex; flex-direction: column;
}
.side-brand {
  display: flex; gap: 10px; align-items: center; padding: 18px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.side-title strong { display: block; color: #fff; font-size: 15px; letter-spacing: .3px; }
.side-title span { font-size: 11px; color: #878ba8; letter-spacing: 1px; }
.side-nav { flex: 1; overflow-y: auto; padding: 10px 10px 12px; }
.side-nav::-webkit-scrollbar { width: 4px; }
.side-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); border-radius: 4px; }
.nav-group { font-size: 11px; color: #6f7392; letter-spacing: 2px; padding: 14px 10px 6px; }
.side-nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px;
  font-size: 13.5px; color: #b9bdd6; margin-bottom: 2px; transition: .15s;
}
.side-nav a .ico { width: 18px; display: inline-flex; justify-content: center; font-style: normal; opacity: .9; }
.side-nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.side-nav a.active { background: var(--brand-grad); color: #fff; box-shadow: 0 8px 18px -8px rgba(80,70,229,.7); }
.side-foot { padding: 12px; border-top: 1px solid rgba(255,255,255,.07); }
.side-user { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.avatar {
  width: 36px; height: 36px; border-radius: 10px; background: var(--brand-grad);
  color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 14px; flex: none;
}
.user-meta strong { display: block; color: #fff; font-size: 13.5px; }
.user-meta span { font-size: 11.5px; color: #878ba8; }
.legacy-link { display: block; text-align: center; font-size: 11.5px; color: #6f7392; margin-top: 10px; }
.legacy-link:hover { color: #b9bdd6; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 58px; flex: none; display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; background: rgba(255,255,255,.82); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar h2 { font-size: 16.5px; font-weight: 600; }
.content { flex: 1; overflow-y: auto; padding: 20px 24px 32px; }

/* ── 登录页 ──────────────────────────── */
.login-wrap { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; }
.login-bg { position: absolute; inset: 0; background: linear-gradient(135deg, #101228 0%, #201a4d 55%, #3b2a86 100%); overflow: hidden; }
.login-grid {
  position: absolute; inset: 0;
  background-image: linear-gradient(rgba(255,255,255,.045) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.045) 1px, transparent 1px);
  background-size: 44px 44px; mask-image: radial-gradient(ellipse at center, #000 20%, transparent 75%);
}
.login-card {
  position: relative; width: 400px; background: rgba(255,255,255,.97); border-radius: 22px;
  padding: 38px 36px 26px; box-shadow: 0 30px 80px -20px rgba(0,0,0,.55); text-align: center;
}
.login-brand h1 { font-size: 22px; margin-top: 14px; letter-spacing: .5px; }
.brand-sub { color: var(--ink-3); font-size: 12.5px; letter-spacing: 4px; margin-top: 4px; }
.login-tip { margin: 18px 0 6px; font-size: 12.5px; color: var(--brand); background: var(--brand-soft); border-radius: 999px; padding: 6px 14px; display: inline-block; }
.login-form { text-align: left; margin-top: 18px; }
.login-form input { margin: 4px 0 14px; padding: 11px 14px; }
.login-error { background: #fdeaea; color: var(--err); font-size: 12.5px; padding: 8px 12px; border-radius: 8px; margin-bottom: 12px; }
.login-foot { margin-top: 18px; font-size: 11px; color: var(--ink-3); letter-spacing: .5px; }

/* ── 通用小组件 ──────────────────────────── */
.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.page-head p { color: var(--ink-3); font-size: 13px; margin-top: 4px; }
.grid { display: grid; gap: 16px; }
.grid.c2 { grid-template-columns: repeat(2, 1fr); }
.grid.c3 { grid-template-columns: repeat(3, 1fr); }
.grid.c4 { grid-template-columns: repeat(4, 1fr); }

.stat { padding: 18px 20px; position: relative; overflow: hidden; }
.stat .k { font-size: 12.5px; color: var(--ink-3); display: flex; align-items: center; gap: 6px; }
.stat .v { font-size: 26px; font-weight: 700; margin-top: 6px; font-family: "DIN Alternate", "Bahnschrift", sans-serif; }
.stat .sub { font-size: 12px; color: var(--ink-3); margin-top: 4px; }
.stat::after { content: ""; position: absolute; right: -22px; top: -22px; width: 90px; height: 90px; border-radius: 50%; background: var(--brand-soft); opacity: .8; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; color: var(--ink-3); font-weight: 500; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 11px 12px; border-bottom: 1px solid #f2f3f8; vertical-align: top; }
.tbl tr:hover td { background: #fafaff; }
.tbl .empty { text-align: center; color: var(--ink-3); padding: 32px 0; }

.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 120px 1fr 90px; gap: 12px; align-items: center; font-size: 12.5px; }
.bar-track { height: 8px; background: #eef0f5; border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: var(--brand-grad); transition: width .5s; }
.bar-val { text-align: right; color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* ── 对话中心 ──────────────────────────── */
.chat-layout { display: grid; grid-template-columns: 250px 1fr; gap: 16px; height: calc(100vh - 58px - 52px); }
.conv-list { display: flex; flex-direction: column; overflow: hidden; }
.conv-list .list { flex: 1; overflow-y: auto; padding: 8px; }
.conv-item { padding: 10px 12px; border-radius: 10px; cursor: pointer; margin-bottom: 4px; border: 1px solid transparent; }
.conv-item:hover { background: #f6f6fd; }
.conv-item.active { background: var(--brand-soft); border-color: #d8d9fb; }
.conv-item .t { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-item .m { font-size: 11.5px; color: var(--ink-3); margin-top: 3px; }

.chat-panel { display: flex; flex-direction: column; overflow: hidden; }
.chat-scroll { flex: 1; overflow-y: auto; padding: 20px 22px; }
.msg { display: flex; gap: 12px; margin-bottom: 18px; }
.msg .who { width: 32px; height: 32px; border-radius: 9px; flex: none; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; }
.msg.user .who { background: #eef0f5; color: var(--ink-2); }
.msg.ai .who { background: var(--brand-grad); color: #fff; }
.msg .bubble { max-width: 78%; min-width: 0; }
.msg .bubble .name { font-size: 12px; color: var(--ink-3); margin-bottom: 5px; }
.msg .bubble .body { background: #fff; border: 1px solid var(--line); padding: 12px 15px; border-radius: 4px 14px 14px 14px; font-size: 14px; line-height: 1.75; white-space: pre-wrap; word-break: break-word; }
.msg.user .bubble .body { background: var(--brand-grad); border: none; color: #fff; border-radius: 14px 4px 14px 14px; }
.tool-block { border: 1px dashed #cdc9f6; background: #f8f7ff; border-radius: 10px; padding: 10px 12px; margin: 10px 0; font-size: 12.5px; }
.tool-block .th { color: var(--brand); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.tool-block pre { font-size: 11.5px; color: var(--ink-2); white-space: pre-wrap; word-break: break-all; margin-top: 6px; max-height: 160px; overflow-y: auto; font-family: Consolas, monospace; }
.cite-block { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 8px; }
.cite-block .ct { font-size: 12px; color: var(--ink-3); margin-bottom: 6px; }
.cite-item { font-size: 12px; color: var(--ink-2); background: #f6f7fb; border-radius: 8px; padding: 6px 10px; margin-bottom: 4px; display: flex; gap: 8px; justify-content: space-between; }
.typing-dot { display: inline-flex; gap: 4px; padding: 4px 0; }
.typing-dot i { width: 6px; height: 6px; border-radius: 50%; background: var(--brand); opacity: .4; animation: blink 1.2s infinite; }
.typing-dot i:nth-child(2) { animation-delay: .2s; }
.typing-dot i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .3; } 40% { opacity: 1; } }

.composer { border-top: 1px solid var(--line); padding: 14px 16px; background: #fcfcfe; }
.composer-row { display: flex; gap: 10px; align-items: flex-end; }
.composer textarea { flex: 1; resize: none; min-height: 46px; max-height: 150px; line-height: 1.6; }
.composer-tools { display: flex; gap: 10px; align-items: center; margin-bottom: 9px; flex-wrap: wrap; }
.composer-tools select { width: auto; padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.kb-chip { font-size: 12px; background: var(--brand-soft); color: var(--brand); border-radius: 999px; padding: 4px 12px; display: inline-flex; gap: 6px; align-items: center; }

/* ── 任务智能体 ──────────────────────────── */
.task-new { display: flex; gap: 10px; margin-bottom: 16px; }
.task-new input { flex: 1; padding: 12px 16px; font-size: 14.5px; border-radius: 12px; }
.task-detail { display: grid; grid-template-columns: 1fr 360px; gap: 16px; align-items: start; }
.step-line { position: relative; padding-left: 24px; }
.step-line::before { content: ""; position: absolute; left: 8px; top: 8px; bottom: 8px; width: 2px; background: var(--line); }
.step-item { position: relative; margin-bottom: 14px; }
.step-item .dot {
  position: absolute; left: -24px; top: 4px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; border: 2px solid var(--line); z-index: 1;
}
.step-item.succeeded .dot { background: var(--ok); border-color: var(--ok); }
.step-item.running .dot { border-color: var(--run); background: #dbe7fe; animation: pulse 1.4s infinite; }
.step-item.failed .dot { background: var(--err); border-color: var(--err); }
.step-item.waiting_confirm .dot { background: var(--warn); border-color: var(--warn); animation: pulse 1.4s infinite; }
.step-item.cancelled .dot { background: var(--ink-3); border-color: var(--ink-3); }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(37,99,235,.35); } 50% { box-shadow: 0 0 0 6px rgba(37,99,235,0); } }
.step-body { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.step-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.step-head .nm { font-weight: 600; font-size: 13.5px; }
.step-meta { font-size: 11.5px; color: var(--ink-3); display: flex; gap: 8px; flex-wrap: wrap; margin-top: 3px; }
.step-out { font-size: 12.5px; color: var(--ink-2); background: #f8f9fd; border-radius: 8px; padding: 10px 12px; margin-top: 10px; white-space: pre-wrap; max-height: 220px; overflow-y: auto; word-break: break-word; }
.result-body { font-size: 13.5px; line-height: 1.8; white-space: pre-wrap; word-break: break-word; }

/* ── 连接器市场 ──────────────────────────── */
.conn-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
.conn-card { padding: 20px; }
.conn-top { display: flex; gap: 14px; align-items: flex-start; }
.conn-icon { width: 46px; height: 46px; border-radius: 13px; background: var(--brand-grad); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 20px; flex: none; }
.conn-name { font-size: 15.5px; font-weight: 600; }
.conn-cat { font-size: 12px; color: var(--ink-3); margin-top: 2px; display: flex; gap: 6px; align-items: center; }
.conn-desc { font-size: 12.5px; color: var(--ink-2); line-height: 1.7; margin: 12px 0; }
.cap-list { font-size: 12px; }
.cap-dom { margin-bottom: 7px; }
.cap-dom b { color: var(--brand); font-weight: 600; margin-right: 6px; }
.cap-dom span { color: var(--ink-3); }

/* ── 知识库 / 智能体 ──────────────────────────── */
.kb-item { padding: 16px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.kb-item .nm { font-weight: 600; font-size: 14px; }
.kb-item .ds { font-size: 12px; color: var(--ink-3); margin-top: 4px; }
.agent-card { padding: 18px 20px; transition: .15s; cursor: pointer; }
.agent-card:hover { transform: translateY(-2px); box-shadow: 0 14px 32px -14px rgba(22,25,44,.2); }
.agent-head { display: flex; gap: 12px; align-items: center; }
.agent-head .nm { font-weight: 600; font-size: 14.5px; }
.agent-head .hd { font-size: 11.5px; color: var(--ink-3); }
.agent-desc { font-size: 12.5px; color: var(--ink-2); margin-top: 12px; line-height: 1.7;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 42px; }
.agent-foot { display: flex; justify-content: space-between; margin-top: 14px; font-size: 11.5px; color: var(--ink-3); }

/* ── 办公创作 ──────────────────────────── */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.tpl-card { padding: 22px 20px; text-align: left; cursor: pointer; transition: .16s; border: 1px solid var(--line); }
.tpl-card:hover { transform: translateY(-3px); border-color: #cbcdfa; box-shadow: 0 16px 36px -16px rgba(80,70,229,.35); }
.tpl-ico { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 21px; color: #fff; margin-bottom: 14px; }
.tpl-card .nm { font-weight: 600; font-size: 14.5px; }
.tpl-card .ds { font-size: 12px; color: var(--ink-3); margin-top: 6px; line-height: 1.65; min-height: 38px; }

/* ── 模态 & Toast ──────────────────────────── */
.modal-mask { position: fixed; inset: 0; background: rgba(16,18,40,.5); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; z-index: 90; animation: fadein .15s; }
@keyframes fadein { from { opacity: 0; } }
.modal { width: 520px; max-width: calc(100vw - 40px); max-height: calc(100vh - 90px); overflow-y: auto; background: #fff; border-radius: 18px; padding: 24px; }
.modal h3 { font-size: 16px; margin-bottom: 16px; }
.modal .form-row { margin-bottom: 13px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.toast-box { position: fixed; top: 18px; right: 18px; z-index: 99; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: #16192c; color: #fff; font-size: 13px; padding: 11px 18px; border-radius: 12px;
  box-shadow: 0 12px 30px -10px rgba(0,0,0,.4); animation: slidein .2s; max-width: 360px;
}
.toast.ok::before { content: "✓ "; color: #4ade80; }
.toast.err::before { content: "✕ "; color: #f87171; }
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } }

/* markdown 渲染 */
.result-body h1, .result-body h2 { font-size: 15px; margin: 14px 0 8px; }
.result-body table { border-collapse: collapse; margin: 10px 0; font-size: 12.5px; }
.result-body th, .result-body td { border: 1px solid var(--line); padding: 5px 10px; }
.md { line-height: 1.85; }
.md h3 { margin: 12px 0 6px; font-size: 14.5px; }
.md ul, .md ol { padding-left: 20px; margin: 6px 0; }
.md code { background: #f0f1f7; border-radius: 4px; padding: 1px 5px; font-size: 12.5px; }
.md strong { color: var(--brand); }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #d4d6e3; border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 1100px) {
  .grid.c4 { grid-template-columns: repeat(2, 1fr); }
  .grid.c3 { grid-template-columns: 1fr; }
  .task-detail { grid-template-columns: 1fr; }
  .chat-layout { grid-template-columns: 200px 1fr; }
}
