:root {
  --bg: #f3f6f5;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #0f766e;
  --primary-dark: #0d9488;
  --border: #e5e7eb;
  --user: #ecfdf5;
  --bot: #f8fafc;
  --danger: #b91c1c;
  --accent-soft: #ccfbf1;
  --ink: #134e4a;
  --cherry: #e11d48;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: linear-gradient(180deg, #e8f5f3 0%, var(--bg) 220px);
  color: var(--text);
}
body.app-shell {
  background: #eef2f1;
  min-height: 100vh;
  display: flex;
}
/* 对话页：整页锁定视口，仅消息区滚动，侧栏始终可见 */
body.app-shell.chat-shell {
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
}
body.app-shell.chat-shell .app-main {
  height: 100vh;
  overflow: hidden;
}
body.app-shell.chat-shell .app-content.chat-page {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding-bottom: 12px;
}
.container { max-width: 1100px; margin: 0 auto; padding: 20px; }
header {
  background: #0f3d3a;
  color: #fff;
  padding: 18px 0 12px;
}
header h1 { margin: 0 0 6px; font-size: 1.4rem; }
header p { margin: 0; opacity: .85; font-size: .92rem; }
header nav { margin-top: 12px; display: flex; gap: 12px; flex-wrap: wrap; }
header nav a { color: #b7ebe4; text-decoration: none; }
header nav a:hover { color: #fff; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.card h2, .card h3 { margin: 0 0 12px; font-size: 1.05rem; }
.muted { color: var(--muted); font-size: .9rem; }
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.kpi {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
}
.kpi-label { color: var(--muted); font-size: .8rem; }
.kpi-value { font-size: 1.25rem; font-weight: 700; margin-top: 4px; }

.quick-links { display: flex; flex-wrap: wrap; gap: 8px; }
.quick-link {
  display: inline-block;
  padding: 8px 12px;
  border-radius: 999px;
  background: #e6f7f5;
  color: #115e59;
  border: 1px solid #99f6e4;
  cursor: pointer;
  text-decoration: none;
  font-size: .88rem;
}
.quick-link:hover { background: #ccfbf1; }

.chat-layout {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 16px;
}
@media (max-width: 900px) {
  .chat-layout { grid-template-columns: 1fr; }
}
.chat-box {
  height: 420px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  background: #fafafa;
}
.msg {
  margin-bottom: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  white-space: pre-wrap;
  line-height: 1.5;
  font-size: .92rem;
}
.msg.user { background: var(--user); border: 1px solid #a7f3d0; }
.msg.assistant { background: var(--bot); border: 1px solid var(--border); }
.msg .role { font-size: .75rem; color: var(--muted); margin-bottom: 4px; }

.chat-input-row { display: flex; gap: 8px; margin-top: 12px; }
.chat-input-row input, .toolbar input, .toolbar select,
.app-content input[type="text"], .app-content input[type="search"],
.app-content input:not([type]), .app-content select, .app-content textarea {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  color: var(--text);
  background: #fff;
  min-height: 38px;
  box-sizing: border-box;
}
.toolbar input, .chat-input-row input { flex: 1; min-width: 160px; }
.toolbar select, .app-content select {
  min-width: 120px;
  max-width: 100%;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236b7280' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}
.app-content input[type="range"] {
  min-height: 0;
  padding: 0;
  border: none;
  background: transparent;
  accent-color: var(--primary);
  height: 28px;
  cursor: pointer;
}
.btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  cursor: pointer;
  font: inherit;
  white-space: nowrap;
}
.btn:hover { background: var(--primary-dark); }
.btn-secondary { background: #334155; }
.btn-secondary:hover { background: #1e293b; }
.toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}
.toolbar label { font-size: .9rem; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* 知识库上传条 / 文件选择 */
.upload-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: 12px 0 14px;
  padding: 12px;
  border: 1px dashed #99f6e4;
  border-radius: 12px;
  background: #f0fdfa;
}
.file-pick {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 220px;
  cursor: pointer;
}
.file-pick input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
}
.file-pick-btn {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--border);
  color: var(--ink);
  font-size: .88rem;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}
.file-pick:hover .file-pick-btn { border-color: #5eead4; color: var(--primary); }
.file-pick-name {
  font-size: .85rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: min(360px, 48vw);
}

/* 锚点区块：侧栏「知识库 / 产物 / 审计」跳转 */
.section-anchor {
  scroll-margin-top: 24px;
}
.section-anchor.section-flash {
  outline: 2px solid rgba(15, 118, 110, .45);
  box-shadow: 0 0 0 6px rgba(20, 184, 166, .16);
  transition: box-shadow .3s ease, outline-color .3s ease;
}

/* 审批流节点行 */
.flow-nodes { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.flow-node {
  display: grid;
  grid-template-columns: 28px minmax(120px, 1.4fr) 120px 120px auto;
  gap: 10px;
  align-items: center;
  padding: 12px 14px !important;
  cursor: grab;
  margin: 0;
}
.flow-node input,
.flow-node select {
  width: 100%;
  min-width: 0;
  flex: unset;
}
.flow-node .flow-idx {
  font-size: .8rem;
  color: var(--muted);
  text-align: center;
}
@media (max-width: 900px) {
  .flow-node {
    grid-template-columns: 24px 1fr;
  }
  .flow-node select,
  .flow-node input[data-f="role"],
  .flow-node .btn { grid-column: 2; }
}

/* What-if 控件条 */
.sim-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 18px;
  align-items: center;
}
.sim-toolbar .sim-field {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid var(--border);
}
.sim-toolbar .sim-field strong {
  min-width: 3.2em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.empty-hint {
  text-align: center;
  color: var(--muted);
  padding: 18px 8px !important;
  border-bottom: none !important;
}
.plugin-card .meta { font-size: .75rem; color: var(--muted); margin: 4px 0 8px; }
.plugin-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: .88rem;
  cursor: pointer;
}
.plugin-toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  min-height: 0;
}

.steps-panel .step {
  border-left: 3px solid var(--primary);
  padding: 8px 10px;
  margin-bottom: 8px;
  background: #f8fffe;
  border-radius: 0 8px 8px 0;
}
.step.fail { border-left-color: var(--danger); background: #fef2f2; }
.step .name { font-weight: 600; }
.step .meta { font-size: .8rem; color: var(--muted); }

table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { border-bottom: 1px solid var(--border); padding: 8px; text-align: left; vertical-align: top; }
th { color: var(--muted); font-weight: 600; }
.clip { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.loading { color: var(--muted); }
code { background: #eef2f7; padding: 1px 5px; border-radius: 4px; }

.side-stack { display: flex; flex-direction: column; gap: 16px; }
.citation-item, .confirm-card, .notif-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 8px;
  background: #fff;
}
.citation-badge {
  display: inline-block;
  background: #ccfbf1;
  color: #115e59;
  border-radius: 999px;
  padding: 1px 8px;
  font-size: .75rem;
  margin-right: 4px;
}
.excerpt { font-size: .85rem; color: #374151; margin-top: 4px; white-space: pre-wrap; }
.confirm-card .btn { margin-top: 8px; }
.notif-item.unread { border-left: 3px solid var(--primary); }
.notif-chip {
  margin-left: auto;
  background: rgba(255,255,255,.12);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: .85rem;
}
.notif-chip strong { color: #fbbf24; }

.attachment-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 8px;
  background: #fff;
}
.attachment-thumb {
  display: block;
  max-width: 100%;
  max-height: 160px;
  margin: 8px 0;
  border-radius: 6px;
  border: 1px solid var(--border);
  object-fit: contain;
  background: #f8fafc;
}
.attachment-dl { display: inline-block; margin-top: 6px; font-size: .85rem; }
.msg-body a { color: var(--primary); word-break: break-all; }

/* ===== App shell / sidebar ===== */
.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: #0f3d3a;
  color: #ecfdf5;
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  align-self: flex-start;
  z-index: 40;
  box-shadow: 4px 0 24px rgba(15, 61, 58, .28);
  border-right: 1px solid rgba(255,255,255,.08);
}
body.app-shell.chat-shell .sidebar {
  position: relative;
  height: 100vh;
  max-height: 100vh;
}
.sidebar-brand {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px;
  background: transparent;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(255,255,255,.14), 0 8px 18px rgba(0,0,0,.28);
  flex-shrink: 0;
}
.brand-mark img {
  width: 36px;
  height: 36px;
  display: block;
  object-fit: cover;
  border-radius: 10px;
}
.brand-title { font-weight: 700; font-size: .95rem; }
.brand-sub { font-size: .72rem; opacity: .7; }
.sidebar-nav {
  padding: 12px 10px 16px;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(153, 246, 228, .35) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 5px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(153, 246, 228, .22);
  border-radius: 999px;
}
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: rgba(153, 246, 228, .42); }
.sidebar-nav a {
  display: block;
  color: #b7ebe4;
  text-decoration: none;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: .9rem;
  margin-bottom: 2px;
}
.sidebar-nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar-nav a.active { background: rgba(20, 184, 166, .25); color: #fff; font-weight: 600; }
.nav-label {
  margin: 14px 12px 6px;
  font-size: .7rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  opacity: .55;
}
.sidebar-foot {
  display: none;
}
.sidebar-user-name {
  color: #f8fafc;
  font-size: .9rem;
  font-weight: 600;
}
.sidebar-user-meta {
  color: #94a3b8;
  font-size: .75rem;
  margin-top: 2px;
}
.logout-form { margin: 0; }
.btn-logout {
  width: 100%;
  border: 1px solid rgba(153, 246, 228, .35);
  background: rgba(15, 118, 110, .35);
  color: #ccfbf1;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: .85rem;
  cursor: pointer;
}
.btn-logout:hover {
  background: rgba(15, 118, 110, .55);
  border-color: rgba(153, 246, 228, .6);
}
.logout-link-fallback {
  display: none;
  color: #99f6e4;
  text-decoration: none;
  font-size: .8rem;
  text-align: center;
}

.app-main {
  flex: 1;
  min-width: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}
.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  z-index: 5;
}
.topbar h1 { margin: 0; font-size: 1.15rem; color: #134e4a; }
.topbar .sub { margin: 2px 0 0; color: var(--muted); font-size: .85rem; }
.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-left: auto;
}
.topbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-left: 14px;
  border-left: 1px solid var(--border);
}
.topbar-user-info { line-height: 1.25; }
.topbar-user-name {
  font-size: .85rem;
  font-weight: 600;
  color: #134e4a;
}
.topbar-user-meta {
  font-size: .72rem;
  color: var(--muted);
  margin-top: 2px;
}
.logout-form-inline { margin: 0; }
.btn-logout-top {
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #475569;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: .8rem;
  cursor: pointer;
  white-space: nowrap;
}
.btn-logout-top:hover {
  background: #f8fafc;
  border-color: #94a3b8;
  color: #0f172a;
}
.app-content {
  padding: 20px 28px 40px;
  max-width: none;
  width: 100%;
  box-sizing: border-box;
  flex: 1;
}

.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 16px;
}
.form-grid .full { grid-column: 1 / -1; }
.form-field label { display: block; font-size: .8rem; color: var(--muted); margin-bottom: 4px; }
.form-field input, .form-field select, .form-field textarea {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
}
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: .75rem;
  background: #e2e8f0;
  color: #334155;
}
.badge.active { background: #ccfbf1; color: #115e59; }
.badge.inactive { background: #fee2e2; color: #991b1b; }
.btn-sm { padding: 6px 10px; font-size: .8rem; border-radius: 6px; }
.btn-danger { background: #b91c1c; }
.btn-ghost { background: transparent; color: var(--primary); border: 1px solid #99f6e4; }
.table-wrap { overflow-x: auto; }

.modal-mask {
  display: none;
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, .45);
  z-index: 50;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-mask.open { display: flex; }
.modal {
  background: #fff;
  border-radius: 14px;
  width: min(640px, 100%);
  max-height: 90vh;
  overflow: auto;
  padding: 18px 20px 16px;
  box-shadow: 0 20px 50px rgba(0,0,0,.18);
}
.modal h3 { margin: 0 0 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.flash { padding: 8px 12px; border-radius: 8px; margin-bottom: 12px; font-size: .88rem; }
.flash.ok { background: #ecfdf5; color: #065f46; }
.flash.err { background: #fef2f2; color: #991b1b; }

@media (max-width: 900px) {
  body.app-shell { flex-direction: column; }
  body.app-shell.chat-shell { height: auto; max-height: none; overflow: auto; }
  body.app-shell.chat-shell .app-main { height: auto; overflow: visible; }
  .sidebar { width: 100%; min-height: auto; height: auto; max-height: none; position: relative; }
  .sidebar-nav { display: flex; flex-wrap: wrap; gap: 4px; }
  .sidebar-nav a { margin: 0; }
  .nav-label { width: 100%; margin: 8px 4px 2px; }
  .topbar { flex-wrap: wrap; }
  .topbar-right { width: 100%; justify-content: flex-end; }
  .topbar-user { border-left: none; padding-left: 0; }
  .form-grid { grid-template-columns: 1fr; }
}

/* ===== Chat workspace ===== */
.chat-page { padding-top: 12px !important; }
.chat-top-actions { align-items: center; }
.chat-top-actions .sess-field {
  display: flex; align-items: center; gap: 6px; font-size: .85rem; color: var(--muted);
}
.chat-top-actions .sess-field input {
  width: 88px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px;
}
.stream-toggle { font-size: .85rem; }
.top-notif {
  background: #0f3d3a !important; color: #fff !important;
  padding: 6px 12px; border-radius: 999px; font-size: .85rem;
}
.top-notif strong { color: #fbbf24; }

.chat-workspace {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) 300px;
  gap: 14px;
  align-items: stretch;
  flex: 1;
  min-height: 0;
  height: 100%;
}

.session-rail {
  display: flex;
  flex-direction: column;
  margin-bottom: 0;
  min-height: 0;
  height: 100%;
  max-height: 100%;
  padding: 0 !important;
  overflow: hidden;
}
.session-rail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 12px 6px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.session-rail-hint {
  margin: 0;
  padding: 6px 12px 8px;
  font-size: .72rem;
  line-height: 1.4;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.session-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px;
}
.session-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: #f8fafc;
  border-radius: 10px;
  padding: 10px 10px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.session-item:hover {
  background: #ecfdf5;
  border-color: #99f6e4;
}
.session-item.active {
  background: #ccfbf1;
  border-color: #14b8a6;
  box-shadow: inset 3px 0 0 #0f766e;
}
.session-item-title {
  display: block;
  font-size: .82rem;
  color: #134e4a;
  font-weight: 600;
  line-height: 1.35;
  max-height: 2.7em;
  overflow: hidden;
}
.session-item-meta {
  display: block;
  margin-top: 4px;
  font-size: .7rem;
  color: var(--muted);
}

.chat-main {
  display: flex;
  flex-direction: column;
  margin-bottom: 0;
  min-height: 0;
  height: 100%;
  max-height: 100%;
  padding: 0 !important;
  overflow: hidden;
}
.chat-main-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-main-head .muted { font-size: .8rem; margin-left: 8px; }
.workspace-bar { flex-shrink: 0; }

.chat-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  scroll-behavior: smooth;
}
.chat-main .chat-box {
  flex: none;
  height: auto;
  min-height: 0;
  overflow: visible;
  border: none;
  border-radius: 0;
  background: transparent;
  padding: 16px 18px 24px;
}
.composer {
  border-top: 1px solid var(--border);
  padding: 12px 14px 14px;
  background: #fff;
  flex-shrink: 0;
  z-index: 3;
  box-shadow: 0 -6px 16px rgba(15, 23, 42, .06);
}
.composer-row { display: flex; gap: 8px; align-items: flex-end; }
.composer-row textarea {
  flex: 1;
  resize: none;
  min-height: 42px;
  max-height: 140px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font: inherit;
  line-height: 1.4;
}
.composer-hint { margin-top: 6px; font-size: .78rem; }

.chat-welcome {
  max-width: 640px;
  margin: 24px auto 8px;
  text-align: center;
  padding: 8px 8px 20px;
}
.welcome-icon {
  width: 52px; height: 52px; margin: 0 auto 12px;
  border-radius: 14px;
  background: linear-gradient(135deg, #14b8a6, #0f766e);
  color: #fff; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 20px rgba(15, 118, 110, .25);
}
.chat-welcome h2 { margin: 0 0 8px; font-size: 1.25rem; color: #134e4a; }
.chat-welcome p { margin: 0 0 18px; color: var(--muted); font-size: .92rem; line-height: 1.5; }
.welcome-chips {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
}
.chip {
  border: 1px solid #99f6e4;
  background: #fff;
  color: #0f766e;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: .82rem;
  cursor: pointer;
  transition: background .15s, transform .15s;
}
.chip:hover { background: #ecfdf5; transform: translateY(-1px); }

.chat-side { min-width: 0; min-height: 0; height: 100%; }
.side-tabs {
  margin-bottom: 0;
  padding: 0 !important;
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: 100%;
  overflow: hidden;
}
.tab-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 8px 8px 0;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
  flex-shrink: 0;
}
.tab {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 8px 10px;
  font-size: .8rem;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
}
.tab.active {
  background: #fff;
  color: #0f766e;
  font-weight: 600;
  box-shadow: 0 -1px 0 #fff;
}
.tab-panels { flex: 1; min-height: 0; overflow-y: auto; padding: 12px; background: #fff; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.empty-hint {
  color: var(--muted);
  font-size: .85rem;
  line-height: 1.55;
  padding: 12px 4px;
  text-align: center;
}

@media (max-width: 1280px) {
  .chat-workspace { grid-template-columns: 200px minmax(0, 1fr) 260px; }
}
@media (max-width: 1100px) {
  .chat-workspace {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }
  body.app-shell.chat-shell .app-content.chat-page { overflow-y: auto; }
  .session-rail { max-height: 220px; height: auto; }
  .chat-main { max-height: min(70vh, 640px); height: min(70vh, 640px); }
  .side-tabs { max-height: 360px; height: auto; }
}

/* ===== Dashboard / 运营概览 ===== */
.dash-page { padding-top: 12px !important; }
.dash-kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.dash-kpi {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 14px 12px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .04);
  position: relative;
  overflow: hidden;
}
.dash-kpi::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: currentColor;
}
.dash-kpi-icon {
  width: 36px; height: 36px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: .85rem; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.dash-kpi .kpi-label { font-size: .75rem; color: var(--muted); }
.dash-kpi .kpi-value { font-size: 1.2rem; font-weight: 750; margin-top: 2px; letter-spacing: -.02em; }
.dash-kpi .kpi-foot { font-size: .72rem; color: #94a3b8; margin-top: 4px; }

.accent-teal { color: #0f766e; }
.accent-teal .dash-kpi-icon { background: linear-gradient(135deg, #14b8a6, #0f766e); }
.accent-blue { color: #2563eb; }
.accent-blue .dash-kpi-icon { background: linear-gradient(135deg, #60a5fa, #2563eb); }
.accent-amber { color: #d97706; }
.accent-amber .dash-kpi-icon { background: linear-gradient(135deg, #fbbf24, #d97706); }
.accent-violet { color: #7c3aed; }
.accent-violet .dash-kpi-icon { background: linear-gradient(135deg, #a78bfa, #7c3aed); }
.accent-rose { color: #e11d48; }
.accent-rose .dash-kpi-icon { background: linear-gradient(135deg, #fb7185, #e11d48); }
.accent-slate { color: #475569; }
.accent-slate .dash-kpi-icon { background: linear-gradient(135deg, #94a3b8, #475569); }
.accent-emerald { color: #059669; }
.accent-emerald .dash-kpi-icon { background: linear-gradient(135deg, #34d399, #059669); }

.dash-chart-grid {
  display: grid;
  grid-template-columns: 1.2fr .8fr;
  gap: 16px;
  margin-bottom: 16px;
}
.chart-span-2 { grid-column: 1 / -1; }
.chart-card { margin-bottom: 0; }
.chart-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 8px;
}
.chart-card-head h2 { margin: 0 0 4px; }
.chart-badge {
  font-size: .72rem;
  padding: 4px 8px;
  border-radius: 999px;
  background: #ccfbf1;
  color: #115e59;
  white-space: nowrap;
}
.chart-badge.soft { background: #e0e7ff; color: #3730a3; }
.chart-wrap { height: 260px; position: relative; }
.chart-wrap-sm { height: 220px; }
.chart-wrap-wide { height: 280px; }
.compact-table { margin-top: 8px; }
.compact-table table { font-size: .82rem; }
.region-dot {
  display: inline-block;
  width: 8px; height: 8px; border-radius: 50%;
  margin-right: 6px; vertical-align: middle;
  background: #0f766e;
}
.tool-legend {
  list-style: none; margin: 8px 0 0; padding: 0;
  display: grid; gap: 6px;
}
.tool-legend li {
  display: flex; align-items: center; gap: 8px;
  font-size: .8rem; color: #334155;
}
.tool-legend .lg-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.tool-legend .lg-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool-legend strong { color: #0f172a; }

.dash-ops-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.pill {
  font-size: .75rem;
  padding: 3px 9px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #334155;
}
.pill.warn { background: #ffedd5; color: #9a3412; }
.pill.info { background: #dbeafe; color: #1e40af; }
.prio {
  font-size: .75rem;
  padding: 2px 6px;
  border-radius: 6px;
  background: #f1f5f9;
}

@media (max-width: 1000px) {
  .dash-chart-grid, .dash-ops-grid { grid-template-columns: 1fr; }
  .chart-span-2 { grid-column: auto; }
}

/* ===== Home / 控制台 ===== */
.home-page { padding-top: 12px !important; }
.home-hero {
  display: grid;
  grid-template-columns: 1.4fr .9fr;
  gap: 18px;
  margin-bottom: 16px;
  padding: 22px 24px;
  border-radius: 18px;
  background:
    radial-gradient(ellipse at 12% 20%, rgba(20, 184, 166, .28), transparent 45%),
    radial-gradient(ellipse at 90% 10%, rgba(37, 99, 235, .18), transparent 40%),
    linear-gradient(135deg, #0f3d3a 0%, #134e4a 45%, #0f766e 100%);
  color: #ecfdf5;
  box-shadow: 0 16px 40px rgba(15, 61, 58, .22);
}
.hero-eyebrow {
  margin: 0 0 6px;
  font-size: .75rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  opacity: .75;
}
.home-hero-copy h2 {
  margin: 0 0 10px;
  font-size: 1.55rem;
  font-weight: 750;
}
.home-hero-copy > p {
  margin: 0 0 16px;
  max-width: 520px;
  line-height: 1.6;
  opacity: .9;
  font-size: .95rem;
}
.home-hero-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.home-hero-actions .btn-ghost {
  background: rgba(255,255,255,.12);
  color: #fff;
  border: 1px solid rgba(255,255,255,.28);
}
.home-hero-actions .btn-ghost:hover { background: rgba(255,255,255,.2); }
.home-hero-stats {
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 14px;
  padding: 16px 18px;
  backdrop-filter: blur(6px);
}
.hero-stat-val {
  font-size: 1.7rem;
  font-weight: 750;
  letter-spacing: -.03em;
}
.hero-stat-label { font-size: .8rem; opacity: .75; margin-top: 2px; }
.hero-stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(255,255,255,.15);
}
.hero-stat-row strong { display: block; font-size: 1.15rem; }
.hero-stat-row span { font-size: .75rem; opacity: .7; }

.chart-link {
  font-size: .82rem;
  color: #0f766e;
  text-decoration: none;
  white-space: nowrap;
}
.chart-link:hover { text-decoration: underline; }

.home-cap-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.cap-card {
  display: block;
  text-decoration: none;
  color: inherit;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, .04);
  transition: transform .15s, box-shadow .15s;
}
.cap-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(15, 23, 42, .08);
}
.cap-icon {
  width: 40px; height: 40px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; margin-bottom: 10px;
}
.cap-icon.teal { background: linear-gradient(135deg, #14b8a6, #0f766e); }
.cap-icon.blue { background: linear-gradient(135deg, #60a5fa, #2563eb); }
.cap-icon.amber { background: linear-gradient(135deg, #fbbf24, #d97706); }
.cap-icon.rose { background: linear-gradient(135deg, #fb7185, #e11d48); }
.cap-card h3 { margin: 0 0 6px; font-size: 1rem; }
.cap-card p { margin: 0; font-size: .85rem; color: var(--muted); line-height: 1.5; }

.home-bottom-grid {
  display: grid;
  grid-template-columns: 1.3fr .9fr;
  gap: 16px;
}
.demo-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}
.demo-steps li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.step-no {
  width: 28px; height: 28px; border-radius: 50%;
  background: #ccfbf1; color: #115e59;
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 700; flex-shrink: 0;
}
.demo-steps strong { display: block; margin-bottom: 2px; }
.demo-steps p { margin: 0; font-size: .85rem; color: var(--muted); }

.account-list { display: grid; gap: 12px; }
.account-item {
  padding: 12px;
  border-radius: 12px;
  background: #f8fafc;
  border: 1px solid var(--border);
}
.account-role { font-size: .75rem; color: var(--muted); margin-bottom: 4px; }
.account-cred { font-size: 1rem; margin-bottom: 4px; }
.tip-line { margin-top: 14px; margin-bottom: 0; font-size: .82rem; }

@media (max-width: 1000px) {
  .home-hero, .home-cap-grid, .home-bottom-grid { grid-template-columns: 1fr; }
  .home-cap-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .home-cap-grid { grid-template-columns: 1fr; }
}

/* —— 对话升维：工作区 / 思考链 / 内嵌卡片 / 多模态 —— */
.workspace-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(90deg, #ecfdf5, #f0f9ff);
}
.ws-label {
  font-size: .75rem;
  font-weight: 600;
  color: #0f766e;
  white-space: nowrap;
}
.ws-chips { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; min-width: 120px; }
.ws-chip {
  background: #fff;
  border: 1px solid #99f6e4;
  color: #134e4a;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: .78rem;
}
.ws-actions { display: flex; gap: 6px; }
.ws-empty { font-size: .78rem; }

.identity-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border: 1px solid #99f6e4;
  border-radius: 10px;
  background: #f0fdfa;
  font-size: .82rem;
}
.identity-chip .sess-field input[readonly] {
  background: #ecfeff;
  border-color: #99f6e4;
  max-width: 88px;
}
.identity-chip .sess-field input:not([readonly]) {
  background: #fff;
  max-width: 88px;
}
.id-name { font-weight: 600; color: #134e4a; white-space: nowrap; }
.id-role { white-space: nowrap; }

.plan-card {
  margin: 12px 14px 0;
  padding: 10px 12px;
  border: 1px solid #99f6e4;
  border-radius: 12px;
  background: linear-gradient(135deg, #f0fdfa 0%, #fff 70%);
  animation: thinkIn .35s ease;
}
.plan-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  font-size: .85rem;
}
.plan-strategy {
  font-size: .75rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: #ccfbf1;
  color: #0f766e;
}
.plan-steps {
  margin: 0;
  padding-left: 1.2rem;
  font-size: .8rem;
  color: #334155;
  line-height: 1.55;
}
.plan-steps li { margin: 2px 0; }

.thinking-rail {
  padding: 10px 14px 6px;
  border-bottom: 1px solid var(--border);
  background: #fff;
}
.thinking-title {
  font-size: .72rem;
  color: var(--muted);
  margin-bottom: 8px;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.thinking-phases {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
}
.think-phase {
  display: flex;
  gap: 8px;
  min-width: 140px;
  max-width: 200px;
  padding: 8px 10px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid var(--border);
  opacity: 0;
  transform: translateY(6px);
  animation: thinkIn .35s ease forwards;
}
.think-phase.running { border-color: #5eead4; background: #ecfdf5; }
.think-phase.warn { border-color: #fdba74; background: #fff7ed; }
.think-phase.error { border-color: #fca5a5; background: #fef2f2; }
.think-phase.pending { opacity: .55; }
@keyframes thinkIn {
  to { opacity: 1; transform: translateY(0); }
}
.think-dot {
  width: 8px; height: 8px; margin-top: 5px;
  border-radius: 50%;
  background: #0f766e;
  flex-shrink: 0;
}
.think-phase.running .think-dot {
  animation: pulseDot 1s ease infinite;
}
@keyframes pulseDot {
  50% { transform: scale(1.35); opacity: .6; }
}
.think-label { font-size: .8rem; font-weight: 600; color: #134e4a; }
.think-detail { font-size: .72rem; color: var(--muted); margin-top: 2px; line-height: 1.35; }

.inline-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}
.inline-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}
.inline-card .ic-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 8px;
}
.inline-card.type-kpi { border-left: 3px solid #0f766e; }
.inline-card.type-confirm { border-left: 3px solid #ea580c; }
.inline-card.type-artifact { border-left: 3px solid #2563eb; }
.ic-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.ic-metrics div {
  background: #f8fafc;
  border-radius: 8px;
  padding: 8px;
  text-align: center;
}
.ic-metrics span {
  display: block;
  font-size: .68rem;
  color: var(--muted);
  margin-bottom: 2px;
}
.ic-metrics b { font-size: .88rem; color: #0f172a; word-break: break-all; }
.ic-thumb {
  display: block;
  max-width: 100%;
  max-height: 160px;
  border-radius: 8px;
  margin-bottom: 8px;
  object-fit: contain;
  background: #f1f5f9;
}

.composer.dragover {
  outline: 2px dashed #0f766e;
  outline-offset: -4px;
  background: #ecfdf5;
}
.upload-hint {
  text-align: center;
  font-size: .85rem;
  color: #0f766e;
  padding: 6px 0 2px;
  font-weight: 600;
}
.btn-icon {
  min-width: 42px;
  padding: 8px 10px;
}
.btn-hold {
  white-space: nowrap;
  min-width: 96px;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  cursor: pointer;
}
.btn-hold:disabled {
  opacity: .55;
  cursor: not-allowed;
}
.btn-hold.recording {
  background: #dc2626 !important;
  color: #fff !important;
  border-color: #b91c1c !important;
  animation: pulseRec 1s ease infinite;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, .25);
}
@keyframes pulseRec {
  50% { opacity: .85; transform: scale(1.02); }
}
.btn-sm { padding: 4px 10px; font-size: .78rem; }
