/* T-021前端评审#3:全站统一为老板拍板的 B2 皮肤(暖白+蓝),与首页 index.html 同源 */
:root {
  --bg: #f8f7f4;
  --panel: #ffffff;
  --ink: #1c2534;
  --ink-2: #48536b;
  --muted: #8a91a3;
  --line: #e7e4dd;
  --brand: #2563eb;
  --brand-ink: #ffffff;
  --user: #eef4ff;
  --assistant: #f4f3ef;
  --radius: 12px;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --blue-soft: #eef4ff;
  --surface-2: #fcfbf9;
  --shadow-s: 0 1px 2px rgba(28,37,52,.05), 0 1px 6px rgba(28,37,52,.04);
  --r-m: 12px;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
button { font: inherit; cursor: pointer; border: none; border-radius: 8px; }
button:disabled { opacity: .5; cursor: default; }
.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); padding: 5px 10px; }
.ghost:hover { color: var(--ink); }

/* ── 登录页 ── */
.login-page { display: flex; align-items: center; justify-content: center; }
.login-card {
  background: var(--panel); width: min(360px, 92vw); margin-top: 14vh;
  padding: 28px 26px; border-radius: var(--radius); box-shadow: 0 8px 30px rgba(0,0,0,.06);
  display: flex; flex-direction: column; gap: 12px;
}
.login-card h1 { font-size: 20px; margin: 0; }
.login-card .sub { color: var(--muted); margin: 0 0 8px; font-size: 13px; }
.login-card label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
.login-card input { padding: 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 15px; }
.login-card button[type=submit] { background: var(--brand); color: var(--brand-ink); padding: 11px; font-size: 15px; margin-top: 6px; }
.err { color: #d93025; font-size: 13px; min-height: 18px; }

/* ── 主框架 ── */
.topbar {
  height: 52px; background: var(--panel); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; padding: 0 16px;
}
.brand { font-weight: 600; }
.user { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; }
.layout { display: flex; height: calc(100vh - 52px); }

.sidebar { width: 260px; background: var(--panel); border-right: 1px solid var(--line); overflow-y: auto; padding: 12px; }
.side-title { font-size: 12px; color: var(--muted); padding: 4px 6px 10px; }
.side-group { font-size: 12px; color: var(--brand); font-weight: 600; padding: 12px 6px 6px; }
.role-btn {
  display: flex; flex-direction: column; gap: 2px; width: 100%; text-align: left;
  background: transparent; padding: 9px 10px; border-radius: 8px; color: var(--ink);
}
.role-btn:hover { background: var(--bg); }
.role-btn b { font-size: 14px; }
.role-btn small { color: var(--muted); font-size: 12px; line-height: 1.3; }
.role-btn.active { background: var(--user); }

.side-hint { color: var(--muted); font-size: 11px; font-weight: normal; }
.role-btn.expanded { background: var(--bg); }
.conv-empty { color: var(--muted); font-size: 12px; padding: 4px 8px; }

/* 角色下折叠的历史对话 */
.role-panel { margin: 2px 0 6px 14px; padding-left: 8px; border-left: 2px solid var(--line); }
.role-new {
  display: block; width: 100%; text-align: left; background: transparent;
  color: var(--brand); font-size: 12px; padding: 6px 8px; border-radius: 6px;
}
.role-new:hover { background: var(--bg); }
.conv-item { display: flex; align-items: center; border-radius: 6px; }
.conv-item:hover { background: var(--bg); }
.conv-item.active { background: var(--user); }
.conv-open {
  flex: 1; min-width: 0; padding: 6px 8px; cursor: pointer;
  display: flex; flex-direction: column; gap: 1px;
}
.conv-title {
  font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conv-time { font-size: 11px; color: var(--muted); }
.conv-del { background: transparent; color: var(--muted); font-size: 12px; padding: 4px 8px; opacity: 0; }
.conv-item:hover .conv-del { opacity: 1; }
.conv-del:hover { color: #d93025; }

/* 模型标注 + 生成中状态 */
.model-tag { font-size: 11px; color: var(--muted); margin-top: 3px; }
.bubble.generating { color: var(--muted); font-style: italic; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: .45; } 50% { opacity: 1; } }

/* Markdown 渲染(表格 / 标题 / 列表等),让脚本表格显示成真表格、可复制 */
.bubble.md { white-space: normal; }
.bubble.md > :first-child { margin-top: 0; }
.bubble.md > :last-child { margin-bottom: 0; }
.bubble.md p { margin: 6px 0; }
.bubble.md h3, .bubble.md h4, .bubble.md h5, .bubble.md h6 { margin: 12px 0 5px; font-size: 15px; }
.bubble.md ul, .bubble.md ol { margin: 6px 0; padding-left: 20px; }
.bubble.md li { margin: 2px 0; }
.bubble.md strong { font-weight: 600; }
.bubble.md code { background: var(--bg); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }
.bubble.md hr { border: none; border-top: 1px solid var(--line); margin: 10px 0; }
.md-table { border-collapse: collapse; margin: 8px 0; font-size: 13px; }
.md-table th, .md-table td { border: 1px solid var(--line); padding: 6px 9px; text-align: left; vertical-align: top; }
.md-table th { background: var(--bg); font-weight: 600; white-space: nowrap; }
.msg.assistant { max-width: 900px; }

.chat { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-header {
  min-height: 56px; padding: 10px 18px; border-bottom: 1px solid var(--line); background: var(--panel);
  display: flex; align-items: center; justify-content: space-between;
}
.chat-header .muted { color: var(--muted); font-size: 13px; margin-top: 2px; }
.placeholder { color: var(--muted); }

.messages { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.msg { display: flex; flex-direction: column; max-width: 760px; }
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.assistant { align-self: flex-start; align-items: flex-start; }
.bubble {
  white-space: pre-wrap; word-break: break-word; line-height: 1.6; font-size: 14.5px;
  padding: 11px 14px; border-radius: var(--radius);
}
.msg.user .bubble { background: var(--user); }
.msg.assistant .bubble { background: var(--assistant); }
.msg.hint .bubble { background: transparent; color: var(--muted); font-size: 13px; padding: 2px 4px; }
.msg-time { font-size: 11px; color: var(--muted); margin-top: 3px; }

/* 分阶段角色顶部引导卡片 */
.stage-guide {
  align-self: flex-start; width: 100%; max-width: 900px;
  background: #f0f6ff; border: 1px solid #c9ddfb; border-radius: 10px;
  padding: 12px 14px; font-size: 13px; line-height: 1.65; color: #2a3442;
}
.stage-guide .sg-title { font-weight: 600; margin-bottom: 4px; }
.stage-guide p { margin: 6px 0; }
.stage-guide p:last-child { margin-bottom: 0; }
.stage-guide .sg-list { margin: 6px 0; padding-left: 20px; }
.stage-guide .sg-list li { margin: 3px 0; }
.stage-guide .sg-note { color: var(--muted); font-size: 12.5px; margin-top: 8px; }
.sg-examples { display: flex; gap: 12px; margin: 8px 0 2px; flex-wrap: wrap; }
.sg-examples figure { margin: 0; }
.sg-examples img { max-height: 190px; max-width: 280px; border: 1px solid #c9ddfb; border-radius: 6px; display: block; background: #fff; cursor: zoom-in; }
.sg-examples figcaption { font-size: 11.5px; color: var(--muted); margin-top: 3px; text-align: center; }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.75); display: flex; align-items: center; justify-content: center; z-index: 1000; cursor: zoom-out; }
.lightbox img { max-width: 92vw; max-height: 92vh; border-radius: 8px; background: #fff; }
.sg-red { color: #d93025; font-weight: 600; }
.copy { background: transparent; color: var(--muted); font-size: 12px; padding: 3px 6px; margin-top: 3px; }
.copy:hover { color: var(--brand); }

/* 运营反馈 👍/👎 + 建议 */
.fb { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 4px; }
.fb-btn { background: transparent; color: var(--muted); font-size: 12px; padding: 3px 8px; border: 1px solid var(--line); border-radius: 6px; }
.fb-btn:hover { color: var(--brand); border-color: var(--brand); }
.fb-box { width: 100%; max-width: 420px; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; font: inherit; font-size: 13px; resize: vertical; }
.fb-done { font-size: 12px; color: #1a7f37; }

/* 角色0 截图上传 */
.img-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.img-hint { font-size: 12px; }
.img-preview { display: flex; gap: 8px; flex-wrap: wrap; width: 100%; }
.img-thumb { position: relative; display: inline-block; }
.img-thumb img { height: 64px; border-radius: 6px; border: 1px solid var(--line); display: block; }
.img-del { position: absolute; top: -6px; right: -6px; background: #d93025; color: #fff; border-radius: 50%; width: 18px; height: 18px; font-size: 11px; line-height: 1; padding: 0; }
.msg-thumbs { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.msg-thumbs img { height: 90px; border-radius: 6px; border: 1px solid var(--line); }

.composer { border-top: 1px solid var(--line); background: var(--panel); padding: 12px 18px; }
.composer-tip {
  background: #fff8e6; border: 1px solid #f0d98c; color: #7a5b00;
  font-size: 12.5px; line-height: 1.55; padding: 8px 11px; border-radius: 8px; margin-bottom: 8px;
}
.composer textarea {
  width: 100%; resize: vertical; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font: inherit; font-size: 14.5px; line-height: 1.5;
  min-height: 72px; max-height: 50vh; overflow-y: auto;
}
.composer-actions { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 8px; }
.status { color: var(--muted); font-size: 13px; margin-right: auto; }
.composer button#send { background: var(--brand); color: var(--brand-ink); padding: 9px 22px; font-size: 14px; }

/* ── 管理后台 ── */
.admin-nav { display: flex; gap: 4px; margin-right: auto; margin-left: 20px; }
.admin-tab { background: transparent; color: var(--muted); padding: 6px 12px; border-radius: 6px; font-size: 14px; }
.admin-tab:hover { color: var(--brand); }
.admin-tab.active { color: var(--brand); background: var(--bg); font-weight: 600; }
.admin-view { height: calc(100vh - 52px); }

/* 知识层管理 */
.kn-layout { display: flex; height: 100%; }
.kn-roles { width: 220px; border-right: 1px solid var(--line); overflow: auto; padding: 10px; background: var(--panel); }
.kn-role { display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: 6px; background: transparent; font-size: 13.5px; }
.kn-role:hover { background: var(--bg); }
.kn-role.sel { background: var(--user); font-weight: 600; }
.kn-main { flex: 1; overflow: auto; padding: 16px; }
.kn-item { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin: 10px 0; }
.kn-item.off { opacity: .55; }
.kn-content { font-size: 13.5px; white-space: pre-wrap; word-break: break-word; }
.kn-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; align-items: flex-start; }
.kn-add { margin-top: 12px; }
.kn-group-title { font-weight: 600; margin: 14px 0 2px; font-size: 13.5px; color: #2a3442; }
.kn-cat-select { border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; font: inherit; font-size: 12.5px; margin-right: 6px; }

/* 驾驶舱 */
.cockpit-wrap { max-width: 980px; margin: 0 auto; padding: 18px 16px 60px; }
.ck-block { margin-bottom: 26px; }
.ck-block h3 { font-size: 15px; margin: 0 0 10px; border-left: 4px solid var(--brand, #2563eb); padding-left: 10px; }
.ck-map { font-size: 13px; }
.ck-lane { background: #f7f9fc; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; display: flex; gap: 10px; align-items: baseline; }
.ck-lane b { white-space: nowrap; }
.ck-lane.ck-loop { background: #f0f9f1; border-color: #c6e5c9; margin-top: 6px; }
.ck-arrow { color: var(--muted); font-size: 12px; padding: 4px 12px; }
.ck-modules { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.ck-mod { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 13px; }
.ck-mod.done { background: #f0f9f1; border-color: #c6e5c9; }
.ck-stage { float: right; font-size: 12px; color: var(--muted); }
.ck-bar { height: 6px; background: #eef1f6; border-radius: 3px; margin: 8px 0 6px; overflow: hidden; }
.ck-bar-in { height: 100%; background: var(--brand, #2563eb); border-radius: 3px; }
.ck-log { border-left: 3px solid var(--brand, #2563eb); padding: 6px 12px; margin: 10px 0; font-size: 13px; background: #fafbfd; border-radius: 0 8px 8px 0; }
.ck-log-head { margin-bottom: 3px; }
.kn-add textarea { width: 100%; max-width: 640px; min-height: 60px; border: 1px solid var(--line); border-radius: 8px; padding: 8px; font: inherit; font-size: 13.5px; margin-bottom: 6px; display: block; resize: vertical; }

/* ── T-021前端评审 统一件 ────────────────────────────── */
/* #5 子页统一顶栏导航(从首页 topnav 抄样,变量已入 :root) */
.topnav { display: flex; align-items: center; gap: 2px; flex: 1; min-width: 0; margin: 0 14px; }
.topnav a { padding: 6px 12px; border-radius: 8px; font-size: 13px; color: var(--ink-2); white-space: nowrap; text-decoration: none; transition: background .15s, color .15s; }
.topnav a:hover { background: var(--blue-soft); color: var(--blue-dark); }
.topnav a.active { background: var(--brand); color: #fff; font-weight: 600; }
/* T-029 动线四步与"偶尔查"入口之间的分隔 */
.nav-sep { width: 1px; height: 18px; background: var(--line, #d3dbe3); margin: 0 6px; flex: none; }
/* #7 等级色/SLA色收敛为首页一套(A琥珀/B蓝/C绿;超期红) */
.lg-lvl.A, .pl-lvl.A, .ac-lvl.A { background: #b45309; }
.lg-lvl.B, .pl-lvl.B, .ac-lvl.B { background: var(--brand); }
.lg-lvl.C, .pl-lvl.C, .ac-lvl.C { background: #15803d; }
.sla.ok { background: #15803d; } .sla.warn { background: #b45309; } .sla.over { background: #dc2626; }
/* #10 数字表格:等宽数字好对位 */
.lg-tbl td { font-variant-numeric: tabular-nums; }
/* #11 admin 后台对齐 B2:tab 胶囊 + 驾驶舱/反馈/知识卡片化 */
.admin-tab.active { background: var(--brand); color: #fff; border-radius: 8px; font-weight: 600; }
.ck-mod, .ck-lane, .fb-card, .kn-item { background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow-s); }

/* 账号机密档案(T-017) */
.acc-card textarea { width: 100%; max-width: 640px; min-height: 44px; border: 1px solid var(--line); border-radius: 8px; padding: 8px; font: inherit; font-size: 13.5px; display: block; resize: vertical; }
.acc-label { font-size: 12.5px; color: #667; margin: 8px 0 4px; }
/* 管理页各处裸用 class="muted" 此前无对应规则(只有 .chat-header .muted),补通用规则 */
.muted { color: var(--muted); }
/* 账号档案网格(T-020批1:横纵排列替代全竖排) */
.acc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 10px; align-items: start; }
.acc-grid .kn-item { margin: 0; }

/* 反馈队列 */
.fb-queue { padding: 16px; overflow: auto; height: 100%; }
.fb-card { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin-bottom: 12px; max-width: 820px; }
.fb-rate { font-size: 15px; margin-right: 6px; }
.fb-snippet { background: var(--bg); border-radius: 6px; padding: 8px; font-size: 12.5px; color: var(--muted); margin: 6px 0; max-height: 140px; overflow: auto; white-space: pre-wrap; }
.fb-adopt-box { width: 100%; max-width: 640px; min-height: 56px; border: 1px solid var(--line); border-radius: 8px; padding: 8px; font: inherit; font-size: 13.5px; margin: 6px 0; display: block; resize: vertical; }
.btn-sm { font-size: 12.5px; padding: 5px 12px; border-radius: 8px; }
.btn-primary { background: linear-gradient(135deg, #2563eb, #1d4ed8); color: var(--brand-ink); box-shadow: 0 1px 4px rgba(37,99,235,.25); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn-ghost:hover { color: var(--brand); border-color: var(--brand); }

/* ── 管理后台日志 ── */
.admin-layout { display: flex; height: calc(100vh - 52px); }
.admin-list { flex: 1; overflow: auto; padding: 12px 16px; }
.admin-detail { width: 440px; border-left: 1px solid var(--line); background: var(--panel); overflow: auto; padding: 14px 16px; }
.log-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.log-table th, .log-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.log-table th { color: var(--muted); font-weight: 600; position: sticky; top: 0; background: var(--bg); }
.log-table tbody tr { cursor: pointer; }
.log-table tbody tr:hover { background: var(--bg); }
.log-table tr.sel { background: var(--user); }
.log-table .ttl { max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.detail-head { margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.log-msg { margin-bottom: 12px; }
.log-who { font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.log-msg .log-body { white-space: pre-wrap; word-break: break-word; font-size: 13px; line-height: 1.5; background: var(--assistant); padding: 8px 10px; border-radius: 8px; }
.log-msg.user .log-body { background: var(--user); }
.sys-prompt { margin: 0 0 14px; }
.sys-toggle { width: 100%; text-align: left; background: #fff7e6; border: 1px solid #ffe0a3; color: #8a6d3b; padding: 8px 10px; border-radius: 8px; font-size: 12.5px; cursor: pointer; }
.sys-toggle:hover { background: #fff0d6; }
.sys-body { white-space: pre-wrap; word-break: break-word; font-size: 12px; line-height: 1.5; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin-top: 6px; max-height: 360px; overflow: auto; }

@media (max-width: 640px) {
  .sidebar { width: 150px; }
  .bubble { font-size: 14px; }
  .admin-detail { display: none; }
}

/* T-046 雷达配置页 */
.rd-wrap { padding: 16px 20px 60px; overflow: auto; height: 100%; }
.rd-block { background: var(--surface,#fff); border: 1px solid var(--line,#e7e4dd); border-radius: 12px; padding: 14px 16px; margin-bottom: 14px; }
.rd-block h3 { margin: 0 0 10px; font-size: 15px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rd-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.rd-row input, .rd-tbl input, .rd-tbl textarea { border: 1px solid var(--line,#e3e8f0); border-radius: 8px; padding: 5px 8px; font: inherit; font-size: 13px; }
.rd-tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.rd-tbl th, .rd-tbl td { border: 1px solid var(--line,#e3e8f0); padding: 6px 8px; text-align: left; vertical-align: top; }
.rd-tbl th { background: var(--blue-soft,#eef4ff); }
.rd-tbl textarea { width: 100%; min-height: 40px; resize: vertical; }
.rd-tbl tr.off td { opacity: .55; }
.rd-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.rd-chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line,#e3e8f0); border-radius: 99px; padding: 2px 10px; font-size: 12.5px; background: #fff; }
.rd-chip.off { opacity: .5; text-decoration: line-through; }
.rd-chip small { color: var(--muted,#6b7280); }
.rd-chip button { border: 0; background: transparent; cursor: pointer; font-size: 12px; color: var(--muted,#6b7280); padding: 0 2px; }

/* T-088 T-1.2b 关键词轮排表 */
.kw-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.kw-table th, .kw-table td { border-bottom: 1px solid var(--line); padding: 8px 6px; text-align: left; vertical-align: top; }
.kw-table th { font-size: 12.5px; color: #667; font-weight: 600; background: #fafafa; }
.kw-table td:nth-child(3) { width: 34%; }
