:root {
  --blue: #267ef0;
  --blue-dk: #1f68c5;
  --bg: #f4f6f9;
  --panel: #ffffff;
  --line: #e4e8ee;
  --text: #101828;
  --text-2: #5b6675;
  --text-3: #8d97a6;
  --ok: #0f9960;
  --ok-bg: #eaf7f0;
  --warn: #b3671d;
  --warn-bg: #fdf3e6;
  --err: #aa352d;
  --err-bg: #fdecea;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--blue-dk); }
code, .mono { font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; }

/* ---------------------------------------------------------------- mobile topbar */
.mobile-topbar {
  display: none; align-items: center; gap: 12px;
  position: sticky; top: 0; z-index: 60;
  background: #fff; border-bottom: 1px solid var(--line);
  padding: 10px 14px; min-height: 52px;
}
.nav-toggle {
  display: flex; flex-direction: column; justify-content: center; gap: 4px;
  width: 38px; height: 38px; padding: 8px 9px;
  background: #fff; border: 1px solid var(--line); border-radius: 9px; cursor: pointer;
}
.nav-toggle span { display: block; height: 2px; border-radius: 2px; background: var(--text-2); }
.mtb-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.mtb-title strong { font-size: 13.5px; }
.mtb-title span { font-size: 11px; color: var(--text-3); }
.mtb-logout { font-size: 12.5px; flex: none; }
.nav-mask {
  display: none; position: fixed; inset: 0; z-index: 70;
  background: rgba(16, 24, 40, .45);
}

/* ---------------------------------------------------------------- layout */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; flex: 0 0 232px; background: #fff; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 16px; border-bottom: 1px solid var(--line); }
.brand-logo {
  width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg, #3f8ef7, #267ef0);
  color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 16px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 13.5px; }
.brand-text span { font-size: 11.5px; color: var(--text-3); }
.nav { padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav a {
  padding: 9px 12px; border-radius: 8px; color: var(--text-2); font-size: 13.5px;
}
.nav a:hover { background: #f2f5f9; color: var(--text); }
.nav a.on { background: #e9f2fe; color: var(--blue); font-weight: 600; }
.sidebar-foot { padding: 14px 16px; border-top: 1px solid var(--line); font-size: 11.5px; color: var(--text-3); }
.envline { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.envline code { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 120px; }
.logout { display: inline-block; margin-top: 6px; font-size: 12.5px; }

.main { flex: 1; padding: 22px 26px 60px; min-width: 0; }

/* ---------------------------------------------------------------- pieces */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 20px; margin: 0 0 4px; }
.page-head .sub { color: var(--text-3); font-size: 12.5px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; margin-bottom: 16px; }
.card > h2 { font-size: 14.5px; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.card > h2 .hint { font-weight: 400; font-size: 12px; color: var(--text-3); }

.grid { display: grid; gap: 14px; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1080px) { .grid.c3, .grid.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px) { .grid.c2, .grid.c3, .grid.c4 { grid-template-columns: 1fr; } }

/* ---- 移动端骨架：顶栏 + 抽屉导航 ---- */
@media (max-width: 860px) {
  .mobile-topbar { display: flex; }
  .layout { display: block; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 80;
    width: 264px; flex: none; height: auto;
    transform: translateX(-105%); transition: transform .22s ease;
    box-shadow: 0 0 40px rgba(16, 24, 40, .18);
  }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open .nav-mask { display: block; }
  .main { padding: 14px 14px 48px; }
  .page-head h1 { font-size: 17.5px; }
  .kv { grid-template-columns: 108px 1fr; }
  .conv-toolbar { flex-wrap: wrap; padding: 0 10px; }
  .conv-tabs a { padding: 0 10px; font-size: 12.5px; }
  .conv-toolbar-right { flex-wrap: wrap; padding: 6px 0 8px; gap: 8px; }
  .ws-center-head { flex-wrap: wrap; }
  .ws-center-head .inline { flex: 1 1 100%; justify-content: flex-end; }
  .login-card { width: min(360px, calc(100vw - 28px)); }
  .msg-modal { width: 100vw; height: 100dvh; border-radius: 0; }
}

.stat { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.stat .k { font-size: 12px; color: var(--text-3); }
.stat .v { font-size: 24px; font-weight: 650; margin-top: 4px; letter-spacing: -0.02em; }
.stat .v small { font-size: 12px; font-weight: 400; color: var(--text-3); margin-left: 4px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); font-size: 13px; vertical-align: top; }
th { color: var(--text-3); font-weight: 500; font-size: 12px; background: #fafbfd; }
tbody tr:hover { background: #fafcff; }
td.nowrap, th.nowrap { white-space: nowrap; }
.table-wrap { overflow-x: auto; }

.tag { display: inline-block; padding: 1px 7px; border-radius: 6px; font-size: 11.5px; background: #eef1f6; color: var(--text-2); }
.tag.blue { background: #e9f2fe; color: var(--blue); }
.tag.ok { background: var(--ok-bg); color: var(--ok); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.tag.err { background: var(--err-bg); color: var(--err); }

.alert { border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; font-size: 13px; }
.alert.ok { background: var(--ok-bg); color: var(--ok); }
.alert.error { background: var(--err-bg); color: var(--err); }
.alert.warn { background: var(--warn-bg); color: var(--warn); }
.alert.info { background: #eef4fd; color: var(--blue-dk); }

form.inline, div.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
/* 内联按钮组里的 form 只是「承载一个按钮」的壳，不能带默认外边距把按钮压到下一行 */
.inline > form { margin: 0; }
input[type=text], input[type=password], input[type=file], input[type=number], select, textarea {
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; font-size: 13px;
  background: #fff; color: var(--text); max-width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(38,126,240,.12); }
label.f { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--text-2); }
button, .btn {
  border: 1px solid transparent; border-radius: 8px; padding: 7px 14px; font-size: 13px; cursor: pointer;
  background: var(--blue); color: #fff; font-weight: 500;
}
button:hover, .btn:hover { background: var(--blue-dk); color: #fff; }
button.ghost, .btn.ghost { background: #fff; color: var(--text-2); border-color: var(--line); }
button.ghost:hover, .btn.ghost:hover { background: #f5f7fa; color: var(--text); }
button.danger { background: var(--err); }
button.sm, .btn.sm { padding: 5px 10px; font-size: 12px; }

.kv { display: grid; grid-template-columns: 150px 1fr; gap: 8px 14px; font-size: 13px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; word-break: break-all; }

.empty { text-align: center; color: var(--text-3); padding: 34px 10px; font-size: 13px; }
.pager { display: flex; gap: 6px; align-items: center; justify-content: flex-end; margin-top: 12px; font-size: 13px; }
.pager a, .pager span { padding: 5px 10px; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
.pager .off { color: var(--text-3); background: #f7f9fc; }
.pager .cur { border: none; background: transparent; color: var(--text-2); }

/* 日志类页面的时间筛选条（配合 templates/_logui.html） */
.logfilter { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 0 0 12px; }
.logfilter label.lf { display: inline-flex; gap: 6px; align-items: center; font-size: 12.5px; color: var(--text-2); }
.logfilter input[type=date], .logfilter select { padding: 6px 8px; font-size: 12.5px; }
.pager span.cur { background: var(--blue); border-color: var(--blue); color: #fff; }

pre.code { background: #f7f9fc; border: 1px solid var(--line); border-radius: 9px; padding: 11px 13px; overflow: auto; font-size: 12.5px; margin: 0; max-height: 320px; }

/* ---------------------------------------------------------------- login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(160deg, #eef4fd, #f7f9fc 60%); }
.login-card { width: 360px; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 28px 26px; box-shadow: 0 12px 40px rgba(16,24,40,.07); }
.login-card h1 { font-size: 18px; margin: 0 0 4px; }
.login-card p.sub { color: var(--text-3); font-size: 12.5px; margin: 0 0 20px; }
.login-card .f { margin-bottom: 14px; }
.login-card .f input { width: 100%; }
.login-card button { width: 100%; padding: 9px; margin-top: 4px; }

/* ---------------------------------------------------------------- 会话记录 */
.msg-shell { background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.msg-item { padding: 12px 16px; border-bottom: 1px solid var(--line); }
.msg-item:last-child { border-bottom: none; }
.msg-meta { display: flex; gap: 10px; align-items: center; font-size: 11.5px; color: var(--text-3); margin-bottom: 6px; flex-wrap: wrap; }
.msg-render { min-height: 22px; }
.msg-raw { font-size: 12.5px; color: var(--text-2); }
.viewer-fallback {
  font-size: 12.5px; color: var(--warn); background: var(--warn-bg);
  border-radius: 8px; padding: 0; margin: 10px 14px 0;
}
/* 工作区内提示条：紧凑、不再挤占聊天区（详情默认折叠） */
.ws-center .viewer-fallback { padding: 0; flex: none; }
.hl { background: #fff3cd; border-radius: 3px; padding: 0 2px; }

/* ---------------------------------------------------- 聊天样式会话视图 */
.chat-window {
  background: #f7f9fc; border: 1px solid var(--line); border-radius: 12px;
  margin-bottom: 16px;
  height: calc(100vh - 160px); min-height: 560px; overflow-y: auto;
}
.chat-scroll { padding: 14px 10px 18px; }
.chat-day { text-align: center; margin: 10px 0 14px; }
.chat-day span {
  font-size: 11.5px; color: var(--text-3); background: #eef1f6;
  border-radius: 10px; padding: 2px 12px;
}
.chat-system { text-align: center; margin: 8px 0; }
.chat-system span {
  font-size: 11.5px; color: var(--text-3); background: #eef1f6;
  border-radius: 10px; padding: 2px 12px;
}
.chat-row { display: flex; align-items: flex-start; gap: 9px; margin: 10px 0; padding: 0 8px; }
.chat-row.right { flex-direction: row-reverse; }
.chat-avatar {
  width: 36px; height: 36px; border-radius: 9px; flex: none;
  color: #fff; font-size: 15px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  user-select: none;
}
.chat-body { max-width: 88%; display: flex; flex-direction: column; }
.chat-row.right .chat-body { align-items: flex-end; }
.chat-head { display: flex; gap: 8px; align-items: baseline; margin: 0 2px 3px; flex-wrap: wrap; }
.chat-head .name { font-size: 12.5px; font-weight: 600; color: var(--text-2); max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-head .time { font-size: 11px; color: #a5afbc; }
.chat-bubble {
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 14px; font-size: 14.5px; line-height: 1.65; color: var(--text);
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}
.chat-row.right .chat-bubble { background: #d9ecff; border-color: #c4e0fc; }
.chat-bubble.need-key { border-style: dashed; }
.chat-plain { min-height: 18px; word-break: break-word; }
.chat-plain.muted { color: var(--text-3); font-size: 12.5px; }
.chat-foot { display: flex; gap: 6px; align-items: center; margin-top: 6px; flex-wrap: wrap; }
.chat-foot .tag { font-size: 10.5px; padding: 0 6px; }
.chat-more { font-size: 11.5px; color: var(--text-3); }
.chat-more:hover { color: var(--blue); }

/* ---------------------------------------------------- 参与成员卡片 */
.participants { display: flex; flex-direction: column; gap: 4px; }
.participant {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 8px 6px; border-radius: 10px;
}
.participant:hover { background: #f4f7fb; }
.participant .chat-avatar { width: 32px; height: 32px; font-size: 13px; border-radius: 8px; }
.pt-body { min-width: 0; flex: 1; }
.pt-top { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pt-name { font-size: 13.5px; font-weight: 600; color: var(--text); }
.pt-ids { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 3px; }
.pt-id {
  font-size: 11.5px; color: var(--text-3); background: #f1f4f8;
  border-radius: 6px; padding: 1px 7px;
}

/* 参与成员折叠卡片：默认收起，点击标题展开 */
.participants-card { padding: 0 18px; }
.participants-card > summary {
  list-style: none; cursor: pointer; user-select: none;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 14px 0; font-size: 14.5px; font-weight: 600;
}
.participants-card > summary::-webkit-details-marker { display: none; }
.participants-card > summary .hint { font-weight: 400; font-size: 12px; color: var(--text-3); }
.participants-card > summary .p-toggle {
  flex: none; width: 8px; height: 8px; margin-right: 4px;
  border-right: 2px solid var(--text-3); border-bottom: 2px solid var(--text-3);
  transform: rotate(45deg); transition: transform .15s ease;
}
.participants-card[open] > summary .p-toggle { transform: rotate(225deg); }
.participants-card .participants { padding: 2px 0 14px; }

/* ---------------------------------------------------- 三栏会话工作区 */
.chat-workspace {
  display: grid; grid-template-columns: 300px minmax(0, 1fr) 280px;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  height: calc(100vh - 175px); min-height: 520px; overflow: hidden;
}
.ws-left, .ws-right { display: flex; flex-direction: column; min-height: 0; background: #fafbfd; }
.ws-left { border-right: 1px solid var(--line); }
.ws-right { border-left: 1px solid var(--line); }
.ws-col-head {
  padding: 12px 14px; font-weight: 600; font-size: 13.5px;
  border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px;
  flex: none;
}
.ws-col-head .hint { font-weight: 400; font-size: 12px; color: var(--text-3); }
/* 左栏会话搜索卡片 */
.ws-search {
  flex: none; margin: 10px 10px 0; padding: 12px;
  background: linear-gradient(180deg, #ffffff, #fbfcfe);
  border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 1px 3px rgba(16, 24, 40, .06);
  display: flex; flex-direction: column; gap: 10px;
}
.ws-search-head { display: flex; align-items: center; justify-content: space-between; }
.ws-search-title { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.ws-search-reset { font-size: 11.5px; color: var(--text-3); }
.ws-search-reset:hover { color: var(--blue); }
.ws-field { display: flex; flex-direction: column; gap: 4px; }
.ws-field-label { font-size: 11.5px; color: var(--text-3); }
.ws-field input[type=text], .ws-field input[type=date] {
  width: 100%; min-width: 0; height: 32px; padding: 0 10px;
  font-size: 12.5px; color: var(--text); font-family: inherit;
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.ws-field input:focus {
  border-color: var(--blue); box-shadow: 0 0 0 3px rgba(38, 126, 240, .12);
}
.ws-field input::placeholder { color: #aab2be; }
.ws-field input[name=keyword] {
  padding-left: 29px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='13' height='13' viewBox='0 0 24 24' fill='none' stroke='%23a3acb9' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M21 21l-4.3-4.3'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 9px center;
}
.ws-field input[name=member] {
  padding-left: 29px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='13' height='13' viewBox='0 0 24 24' fill='none' stroke='%23a3acb9' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2'/%3E%3Ccircle cx='12' cy='7' r='4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 9px center;
}
.ws-search-dates { display: flex; align-items: center; gap: 6px; }
.ws-search-dates em { font-style: normal; font-size: 11.5px; color: var(--text-3); flex: none; }
.ws-field input[type=date]::-webkit-calendar-picker-indicator { opacity: .45; cursor: pointer; }
.ws-search-btn {
  height: 32px; border: 0; border-radius: 8px; background: var(--blue);
  color: #fff; font-size: 13px; font-weight: 500; font-family: inherit;
  cursor: pointer; transition: background .15s;
}
.ws-search-btn:hover { background: var(--blue-dk); }
.ws-conv-list { flex: 1; overflow-y: auto; }
/* ---------- 顶部检索工具条（Tab + 统计 + 设置） ---------- */
.conv-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 0 14px; margin-bottom: 10px; min-height: 46px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}
.conv-tabs { display: flex; align-items: stretch; gap: 4px; }
.conv-tabs a {
  position: relative; display: flex; align-items: center;
  padding: 0 14px; height: 46px;
  font-size: 13.5px; font-weight: 500; color: var(--text-2);
  text-decoration: none; transition: color .15s;
}
.conv-tabs a:hover { color: var(--blue); }
.conv-tabs a.on { color: var(--blue); font-weight: 600; }
.conv-tabs a.on::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: 0;
  height: 2.5px; border-radius: 2px 2px 0 0; background: var(--blue);
}
.conv-toolbar-right { display: flex; align-items: center; gap: 14px; }
.conv-stat { font-size: 12px; color: var(--text-3); }
.conv-tool {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12.5px; color: var(--text-2); text-decoration: none;
  padding: 5px 10px; border-radius: 7px; transition: background .15s, color .15s;
}
.conv-tool:hover { background: #f0f5fc; color: var(--blue); }

/* 会话列表：右侧时间 + 命中徽标 */
.ws-conv-time { flex: none; margin-left: auto; font-size: 11px; font-weight: 400; color: var(--text-3); }
.ws-conv-meta { flex: none; font-size: 11px; color: #fff; background: #c3cbd7; border-radius: 8px; padding: 0 6px; line-height: 16px; }
.ws-conv.active .ws-conv-meta { background: var(--blue); }
.ws-hit { color: var(--blue); font-weight: 500; }
.ws-conv { border-radius: 8px; border-bottom: none; margin: 2px 6px; padding: 9px 10px; }
.ws-conv:hover { background: #f2f6fb; }
.ws-conv.active { background: #e8f1ff; }
.ws-conv-list { padding-top: 2px; }

/* 聊天区头部：会话内搜索 + 日期过滤（输入框样式对齐左侧「全部员工」搜索框） */
.chat-filter { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.chat-filter .sp-input { flex: 0 1 150px; min-width: 100px; }
.chat-filter .sp-input input {
  height: 30px; padding: 0 28px 0 10px; font-size: 12.5px; color: var(--text);
  background: #f5f7fa; border: 1px solid var(--line); border-radius: 8px;
}
.chat-filter .sp-input input::placeholder { color: #aab2be; }
.chat-filter .sp-input svg { right: 8px; }
.chat-filter .sp-dates { flex: none; }
.chat-filter .sp-dates input[type=date] {
  width: 106px; height: 30px; padding: 0 8px; font-size: 12px; color: var(--text);
  background: #f5f7fa; border: 1px solid var(--line); border-radius: 8px;
}
.chat-filter .sp-dates em { font-size: 11.5px; }
.chat-filter input:focus {
  background: #fff; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(38, 126, 240, .12);
}
.chat-filter button {
  height: 30px; padding: 0 12px; font-size: 12.5px; font-family: inherit; flex: none;
  border: 0; border-radius: 8px; background: var(--blue); color: #fff; cursor: pointer;
}
.chat-filter button:hover { background: var(--blue-dk); }
.chat-filter-clear { font-size: 12px; color: var(--text-3); flex: none; }
.chat-filter-clear:hover { color: var(--blue); }
.chat-search-warn {
  flex: none; margin: 8px 12px 0; padding: 7px 10px; font-size: 12px; line-height: 1.55;
  color: #8a5a12; background: #fdf3e2; border: 1px solid #f0d9ad; border-radius: 8px;
}
.chat-empty-hint { flex: 1; display: flex; align-items: center; justify-content: center; padding: 20px; }
.chat-empty-hint .empty { text-align: center; line-height: 1.9; }
.ws-center-head { gap: 10px; }

/* ---------- 检索工作台（员工/客户/群聊检索） ---------- */
.search-workspace {
  display: grid; grid-template-columns: 250px 280px 1fr;
  gap: 10px; height: calc(100vh - 150px); min-height: 420px;
}
.search-workspace.two { grid-template-columns: 280px 1fr; }
.sp-left, .sp-mid, .sp-chat {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  display: flex; flex-direction: column; min-height: 0; overflow: hidden;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}
.sp-head, .sp-mid-head {
  flex: none; display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; font-size: 13.5px; font-weight: 600;
  border-bottom: 1px solid var(--line);
}
.sp-searchbar { flex: none; padding: 10px 12px; }
.sp-searchbar.col { display: flex; flex-direction: column; gap: 8px; border-bottom: 1px solid var(--line); }
.sp-input { position: relative; }
.sp-input input {
  width: 100%; height: 32px; padding: 0 30px 0 10px; font-size: 12.5px;
  color: var(--text); font-family: inherit;
  background: #f5f7fa; border: 1px solid var(--line); border-radius: 8px;
  outline: none; transition: border-color .15s, box-shadow .15s, background .15s;
}
.sp-input input:focus { background: #fff; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(38, 126, 240, .12); }
.sp-input input::placeholder { color: #aab2be; }
.sp-input svg { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); pointer-events: none; }
.sp-dates { display: flex; align-items: center; gap: 6px; }
.sp-dates em { font-style: normal; font-size: 11.5px; color: var(--text-3); }
.sp-dates input[type=date] {
  flex: 1; min-width: 0; height: 30px; padding: 0 8px; font-size: 12px;
  color: var(--text); font-family: inherit;
  background: #fff; border: 1px solid var(--line); border-radius: 8px; outline: none;
}
.sp-dates input[type=date]:focus { border-color: var(--blue); }
.sp-list { flex: 1; overflow-y: auto; padding: 4px 6px; }
.sp-more {
  display: block; margin: 6px 4px 10px; padding: 7px 10px; text-align: center;
  font-size: 12.5px; color: var(--blue); text-decoration: none;
  background: #f2f6fb; border: 1px solid var(--line); border-radius: 8px;
}
.sp-more:hover { background: #e8f1ff; border-color: #c7dcf7; }
.sp-more-note {
  margin: 6px 4px 10px; padding: 7px 10px; font-size: 11.5px; line-height: 1.6;
  color: var(--text-3); background: #f7f8fa; border-radius: 8px; text-align: center;
}
.sp-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px; text-decoration: none;
  transition: background .12s;
}
.sp-item:hover { background: #f2f6fb; }
.sp-item.active { background: #e8f1ff; }
.sp-item .chat-avatar { width: 38px; height: 38px; font-size: 15px; border-radius: 9px; flex: none; }
.sp-item-main { flex: 1; min-width: 0; }
.sp-item-top { display: flex; align-items: baseline; gap: 8px; }
.sp-item-name {
  font-size: 13.5px; font-weight: 600; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  flex: 1; min-width: 0;
}
.sp-item-sub { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.sp-item-time { flex: none; font-size: 11px; color: var(--text-3); }
.sp-tabs {
  flex: none; display: flex; gap: 4px; padding: 0 10px;
  border-bottom: 1px solid var(--line);
}
.sp-tabs a {
  position: relative; padding: 9px 10px; font-size: 13px; font-weight: 500;
  color: var(--text-2); text-decoration: none;
}
.sp-tabs a:hover { color: var(--blue); }
.sp-tabs a.on { color: var(--blue); font-weight: 600; }
.sp-tabs a.on::after {
  content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px;
  height: 2.5px; border-radius: 2px; background: var(--blue);
}
.sp-mid-head { min-height: 56px; }
.sp-mid-head strong {
  font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sp-chat { position: relative; }
.sp-chat-head {
  flex: none; display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
  flex-wrap: wrap; row-gap: 8px;
}
.sp-chat-head .chat-avatar { width: 38px; height: 38px; font-size: 15px; border-radius: 9px; flex: none; }
.sp-chat-title { flex: 1 1 240px; min-width: 200px; }
.sp-chat-title strong {
  display: block; font-size: 14.5px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.sp-chat-title .hint { display: block; font-size: 11.5px; }
.sp-chat-head .chat-filter {
  margin-left: auto; flex: 1 1 100%; justify-content: flex-end; gap: 6px; flex-wrap: wrap;
}
.sp-chat-head .chat-filter .sp-input { flex: 1 1 110px; min-width: 90px; }
.sp-chat-head .chat-filter .sp-dates { flex: 0 1 auto; }
.sp-chat-head .chat-filter .sp-dates input[type=date] { flex: 1 1 86px; width: auto; min-width: 60px; }
.sp-chat-head .chat-filter button { flex: none; padding: 0 10px; }
.sp-chat-head .chat-filter em { flex: none; }
/* 允许日期输入在极窄时隐藏内部微调按钮 */
.sp-chat-head .chat-filter input[type=date]::-webkit-inner-spin-button { display: none; }
.sp-chat-body {
  flex: 1; display: flex; flex-direction: column; min-height: 0;
}
.sp-chat-body .ws-chat-area { flex: 1; min-height: 0; }
.sp-chat-empty { flex: 1; display: flex; align-items: center; justify-content: center; }
@media (max-width: 1100px) {
  .search-workspace { grid-template-columns: 200px 230px 1fr; }
}
/* ≤720px：单栏切换。默认显示列表；选中会话后（has-panel）只显示聊天区 */
@media (max-width: 720px) {
  .search-workspace { display: block; height: auto; min-height: 0; }
  .search-workspace > * { margin-bottom: 10px; }
  .search-workspace.has-panel .sp-left,
  .search-workspace.has-panel .sp-mid { display: none; }
  .search-workspace:not(.has-panel) .sp-chat { display: none; }
  .search-workspace .sp-list { max-height: 66vh; }
  .search-workspace .sp-chat-body .chat-window { min-height: 62vh; }
}
/* ≤720px 详情态：详情面板整屏固定（position:fixed + inset:0）。
   不依赖 body→layout→main 的任何祖先高度链，企微安卓/iOS 内核都能铺满全屏；
   面板自带头部（含返回按钮）与消息区，消息区在面板内部滚动。 */
@media (max-width: 720px) {
  body.detail-mode { overflow: hidden; }
  .search-workspace.has-panel,
  .chat-workspace.has-chat {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    z-index: 80;
    display: flex; flex-direction: column;
    width: 100%; height: 100%;
    margin: 0; border-radius: 0;
    background: #f7f9fc; overflow: hidden;
  }
  .search-workspace.has-panel .sp-chat,
  .chat-workspace.has-chat .ws-center {
    flex: 1 1 auto; min-height: 0;
    display: flex; flex-direction: column;
    margin-bottom: 0; border-radius: 0;
  }
  .search-workspace.has-panel .sp-chat-body .chat-window,
  .chat-workspace.has-chat .ws-chat-area .chat-window {
    flex: 1 1 auto; min-height: 0; height: auto; max-height: none;
    margin: 0; border: none; border-radius: 0;
  }
}

.ws-conv {
  display: flex; align-items: center; gap: 10px;
  border-radius: 8px; margin: 2px 6px; padding: 9px 10px; text-decoration: none;
}
.ws-conv:hover { background: #f2f6fb; }
.ws-conv.active { background: #e8f1ff; }
.ws-conv .chat-avatar { width: 36px; height: 36px; font-size: 14px; border-radius: 9px; }
.ws-conv-main { flex: 1; min-width: 0; }
.ws-conv-top { display: flex; align-items: baseline; gap: 8px; }
.ws-conv-name {
  font-size: 13.5px; font-weight: 600; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  flex: 1; min-width: 0;
}
.ws-conv-sub {
  font-size: 11.5px; color: var(--text-3); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ws-pager {
  display: flex; gap: 10px; align-items: center; justify-content: center;
  padding: 8px; border-top: 1px solid var(--line); font-size: 12.5px; flex: none;
}
.ws-center { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.ws-center-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 14px; border-bottom: 1px solid var(--line); flex: none;
  flex-wrap: nowrap;
}
.ws-chat-title { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ws-chat-title strong { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ws-chat-title .hint {
  font-size: 11.5px; color: var(--text-3); margin-left: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ws-center-head .inline { flex: none; display: flex; gap: 6px; }
.ws-center-head .inline button { padding: 4px 10px; font-size: 12.5px; }
.ws-chat-area { flex: 1; min-height: 0; display: flex; flex-direction: column; background: #f7f9fc; }
.ws-chat-area .chat-window {
  flex: 1; height: auto; min-height: 0; width: 100%;
  border: none; border-radius: 0; margin: 0;
}
/* OpenDataFrame 会把渲染节点放进 #viewer-root：
   自定义元素默认 display:inline，height:100% 不生效 → 聊天区永远只有内容高度。
   这里强制块级 + 100% 撑满宿主。 */
.ws-viewer-host { display: flex; flex-direction: column; }
.ws-viewer-host > * {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  flex: 1 1 auto;
}
/* 组件帧根节点（自定义元素）默认是 inline，必须强制块级才会吃满高度 */
.ws-viewer-host ww-open-data-frame,
.ws-viewer-host [class*="open-data-frame"] {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
}
/* ★ 根因：OpenDataFrame 实际渲染成一个 <iframe>，iframe 默认高度 ~150px，
   这就是"聊天区只有一小块"的真正原因。强制 iframe 撑满宿主。 */
.ws-viewer-host iframe {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  border: 0 !important;
  background: transparent !important;
}
.ws-placeholder { flex: 1; display: flex; align-items: center; justify-content: center; }
.ws-login { margin: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: #fff; padding: 12px 14px; }
.ws-login-title { font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.ws-login-title .hint { font-weight: 400; font-size: 12px; color: var(--text-3); }
.ws-participants { padding: 6px 10px; }
.ww-diag {
  margin: 10px 14px 0; border: 1px solid #f0d9a8; background: #fdf6e7;
  border-radius: 8px; font-size: 12.5px; color: #7a5b16; flex: none;
}
.ww-diag summary { cursor: pointer; padding: 7px 10px; font-weight: 600; }
.ww-diag-body { padding: 0 10px 9px; line-height: 1.7; }
.notice-fold { margin: 0; }
.notice-fold summary {
  cursor: pointer; padding: 8px 12px; font-size: 12.5px; font-weight: 600;
  color: #92610e; list-style: none;
}
.notice-fold summary::-webkit-details-marker { display: none; }
.notice-fold[open] summary { border-bottom: 1px dashed #eeddb3; }
.notice-fold .notice-body { padding: 9px 12px 11px; line-height: 1.7; word-break: break-all; }
@media (max-width: 1080px) { .chat-workspace { grid-template-columns: 240px minmax(0, 1fr); } .ws-right { display: none; } }
/* 移动端单栏切换：默认显示会话列表；进入会话（has-chat）后只显示详情，
   由左上「‹ 会话列表」返回。此前固定隐藏列表，手机端永远无法选中会话。 */
.mobile-back {
  display: none; flex: none; align-items: center;
  font-size: 12.5px; color: var(--blue); text-decoration: none;
  padding: 4px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
@media (max-width: 720px) {
  .chat-workspace { grid-template-columns: 1fr; }
  .chat-workspace .ws-left { display: flex; }
  .chat-workspace.has-chat .ws-left { display: none; }
  .chat-workspace:not(.has-chat) .ws-center { display: none; }
  .mobile-back { display: inline-flex; }
  .ws-conv { padding: 11px 12px; }
  .chat-workspace .ws-center-head { gap: 8px; }
}

/* ---------------------------------------------------- 消息内容详情弹窗 */
.msg-modal-mask {
  position: fixed; inset: 0; background: rgba(16, 24, 40, .45);
  z-index: 9990; display: flex; align-items: center; justify-content: center;
}
.msg-modal {
  position: relative; width: min(96vw, 1400px); height: 92vh;
  background: #fff; border-radius: 14px; overflow: hidden;
  box-shadow: 0 18px 60px rgba(16, 24, 40, .3);
  display: flex; flex-direction: column;
}
.msg-modal-head {
  flex: none; display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-bottom: 1px solid var(--line); background: #fafbfd;
}
.msg-modal-head .t { font-size: 13.5px; font-weight: 600; color: var(--text); }
.msg-modal-head .hint { flex: 1; }
.msg-modal-head .btn { padding: 4px 12px; font-size: 12.5px; }
.msg-modal iframe { flex: 1; width: 100%; border: 0; background: #fff; }

/* ---------------------------------------------------- 企业信息配置表单 */
.cfggroup { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 12px; overflow: hidden; background: #fff; }
.cfggroup > summary {
  cursor: pointer; padding: 11px 14px; font-size: 13.5px; font-weight: 600;
  background: #fafbfd; display: flex; align-items: center; gap: 8px; list-style: none;
}
.cfggroup > summary::-webkit-details-marker { display: none; }
.cfggroup > summary::before { content: "▸"; color: var(--text-3); font-size: 11px; transition: transform .15s; }
.cfggroup[open] > summary::before { transform: rotate(90deg); }
.cfggroup > summary .hint { font-weight: 400; font-size: 12px; color: var(--text-3); }
.cfggroup .body { padding: 14px; border-top: 1px solid var(--line); }
.cfggroup .desc { font-size: 12.5px; color: var(--text-3); margin: 0 0 12px; line-height: 1.6; }
.cfgfields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.cfgfields .wide { grid-column: 1 / -1; }
.cfgrow { display: flex; flex-direction: column; gap: 5px; }
.cfgrow > label { font-size: 12px; color: var(--text-2); font-weight: 500; }
.cfgrow > label .req { color: var(--err); margin-left: 2px; }
.cfgrow input[type=text], .cfgrow input[type=password], .cfgrow input[type=number] { width: 100%; }
.cfgrow .help { font-size: 11.5px; color: var(--text-3); line-height: 1.55; }
.cfgrow .mono { font-family: var(--mono, ui-monospace, SFMono-Regular, Menlo, monospace); }
.cfgrow .statusline { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.cfgrow .statusline .clear { font-size: 11.5px; color: var(--text-3); display: inline-flex; align-items: center; gap: 4px; }
.cfgrow.switch { flex-direction: row; align-items: flex-start; gap: 9px; grid-column: 1 / -1; }
.cfgrow.switch > input { margin-top: 2px; }
.cfgrow.switch .txt { display: flex; flex-direction: column; gap: 3px; }
.cfgbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 14px; }
.cfgbar .spacer { flex: 1; }
.cfgbar .note { font-size: 12px; color: var(--text-3); }
@media (max-width: 900px) { .cfgfields { grid-template-columns: 1fr; } }

/* 聊天区底部「加载更多」。消息按最新在上排列，越往下越早，所以「更多 = 更早的记录」，
   入口放底部（往下滚本来就在回溯时间，滚到底它自然就在眼前）。
   做成聊天区 flex 列里的定高尾部条：不参与滚动，降级视图与组件视图都适用；
   点击后原地向下续接、不跳页，见 static/js/viewer.js 的 loadEarlier()。 */
.chat-more-bar {
  flex: none; display: flex; align-items: center; justify-content: center;
  padding: 9px 12px; background: #fff; border-top: 1px solid var(--line);
}
.chat-more-bar.off { display: none; }
.chat-more-bar .load-earlier {
  display: inline-flex; align-items: baseline; gap: 7px;
  padding: 7px 20px; border: 1px solid var(--line); border-radius: 999px;
  background: #fff; color: var(--primary, #1b5da6);
  font-size: 12.5px; text-decoration: none; white-space: nowrap;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
  transition: background .15s, border-color .15s;
}
.chat-more-bar .load-earlier:hover { background: #f2f7ff; border-color: #bcd4f2; color: #0f4c8a; }
.chat-more-bar .cmb-sub { font-size: 11.5px; color: var(--text-3); }
.chat-more-bar .load-earlier:hover .cmb-sub { color: var(--text-2); }
/* 增量加载中（不整页刷新，浏览器没有自带反馈，这里给个禁用态） */
.chat-more-bar .load-earlier[data-loading="1"] {
  color: var(--text-3); background: #f7f9fc; border-color: var(--line); cursor: default;
}
@media (max-width: 900px) {
  .chat-more-bar { padding: 7px 10px; }
  .chat-more-bar .load-earlier { padding: 7px 14px; }
}

/* 顶部导航进度条：整页跳转时给即时反馈，避免"点了没反应"的卡顿观感 */
.nav-progress {
  position: fixed; top: 0; left: 0; right: 0; height: 2px;
  z-index: 9999; opacity: 0; transition: opacity .18s;
  pointer-events: none;
}
.nav-progress.on { opacity: 1; }
.nav-progress span {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, #1b5da6, #4b9ef0);
  box-shadow: 0 0 8px rgba(75, 158, 240, .7);
}
.nav-progress.on span {
  animation: nav-progress-run 9s cubic-bezier(.15,.6,.25,1) forwards;
}
@keyframes nav-progress-run {
  0%   { width: 0; }
  35%  { width: 62%; }
  70%  { width: 84%; }
  100% { width: 96%; }
}

/* ---------------------------------------------------------------- 含正文导出（/export）
   ① 是普通按钮，②③ 由会话展示组件渲染（OpenDataFrame），宿主高度需给足，
   否则组件里的按钮会被压成一条缝。 */
.bex-steps { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.bex-step { display: flex; gap: 12px; padding: 12px 14px; }
.bex-step + .bex-step { border-top: 1px solid var(--line); }
.bex-no {
  flex: none; width: 22px; height: 22px; border-radius: 50%;
  background: var(--blue); color: #fff; font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; margin-top: 1px;
}
.bex-body { min-width: 0; }
.bex-body > b { font-size: 13.5px; }
.bex-desc { color: var(--text-2); font-size: 12.5px; margin-top: 2px; }
.bex-row { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-top: 10px; }
label.f.inline { max-width: 220px; margin: 0; }
.bex-ops {
  margin-top: 14px; border: 1px solid var(--line); border-radius: 10px;
  background: #fbfcfe; padding: 12px 14px;
}
.bex-ops-head {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  font-size: 12.5px; color: var(--text-2); margin-bottom: 10px;
}
.bex-status { color: var(--text-3); font-size: 12.5px; }
.bex-status.ok { color: var(--ok); }
.bex-status.error { color: var(--err); }
.bex-status.warn { color: var(--warn); }
.bex-frame-host {
  min-height: 84px; background: #fff; border: 1px solid var(--line);
  border-radius: 9px; padding: 12px 14px;
}
.bex-frame-host iframe { display: block; width: 100%; min-height: 84px; border: 0; }
.bex-frame-host > div { display: block; width: 100%; }

/* ---------------- 控件美化：下拉框统一自绘箭头（全局生效） ---------------- */
select {
  -webkit-appearance: none; appearance: none;
  padding-right: 30px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238d97a6' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
button, .btn { transition: background .15s, border-color .15s, box-shadow .15s, transform .05s; }
button:active, .btn:active { transform: translateY(1px); }

/* ---------------- 导出页筛选栏（对齐参考稿：标签+控件一行） ---------------- */
.fx-bar { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-end; }
.fx-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.fx-field > .fx-label { font-size: 12.5px; color: var(--text-2); font-weight: 500; line-height: 1.2; }
.fx-field select, .fx-field input[type="date"] {
  height: 36px; padding: 0 10px; font-size: 13px; border-radius: 8px;
  background-color: #fff; border: 1px solid var(--line); color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.fx-field select { padding-right: 30px; min-width: 138px; }
.fx-field input[type="date"] { min-width: 130px; }
.fx-field input[type="date"]:focus, .fx-field select:focus {
  border-color: var(--blue); box-shadow: 0 0 0 3px rgba(38, 126, 240, .12); outline: none;
}
.fx-range { display: flex; align-items: center; gap: 6px; }
.fx-range em { font-style: normal; color: var(--text-3); font-size: 12px; }
.fx-actions { display: flex; gap: 10px; align-items: center; margin-left: auto; }
.fx-actions button {
  height: 36px; padding: 0 18px; font-size: 13.5px; font-weight: 600; border-radius: 8px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .08);
}
.fx-actions button.ghost { font-weight: 500; box-shadow: none; }
.fx-note { margin-top: 12px; font-size: 12px; color: var(--text-3); line-height: 1.6; }
@media (max-width: 900px) { .fx-actions { margin-left: 0; width: 100%; } }

/* ---------------- 含正文导出：三步进度条 ---------------- */
.bex-progress { display: flex; align-items: stretch; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.bex-pstep {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 14px 9px 10px; border: 1px solid var(--line); border-radius: 10px;
  background: #fbfcfe;
}
.bex-pstep i {
  font-style: normal; width: 22px; height: 22px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; background: #eef1f6; color: var(--text-3);
}
.bex-pstep span { display: flex; flex-direction: column; line-height: 1.35; font-size: 13px; font-weight: 600; color: var(--text-2); }
.bex-pstep small { font-weight: 400; font-size: 11.5px; color: var(--text-3); }
.bex-psep { align-self: center; width: 20px; height: 1px; background: var(--line); flex: none; }
.bex-pstep[data-state="doing"] i { background: var(--blue); color: #fff; box-shadow: 0 0 0 4px rgba(38, 126, 240, .14); }
.bex-pstep[data-state="doing"] span { color: var(--text); }
.bex-pstep[data-state="done"] { border-color: #d7eede; background: #f6fcf8; }
.bex-pstep[data-state="done"] i { background: var(--ok); color: #fff; }
.bex-pstep[data-state="done"] span { color: var(--text); }

/* ---------------- 退出登录：POST 表单按钮做成链接外观 ---------------- */
.logout-form { margin: 0; display: flex; }
.logout-form.mtb-logout-form { flex: none; }
.logout-form button {
  background: none; border: 0; padding: 0; box-shadow: none; cursor: pointer;
  color: var(--blue); font-family: inherit; font-weight: 400; font-size: 12.5px;
  line-height: 1.6; text-align: left;
}
.logout-form button:hover { background: none; color: var(--blue-dk); text-decoration: underline; }
.logout-form button:active { transform: none; }
.logout-form button.mtb-logout { padding: 0; }

/* ================= 离职员工记录查看（/records 只读页 + /grants 授权管理） ================= */
.rec-title { font-size: 13.5px; font-weight: 650; color: var(--text); }
.rec-audit {
  font-size: 11.5px; color: var(--text-3); margin-left: 10px;
  padding-left: 10px; border-left: 1px solid var(--line);
}
.rec-targets { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12px; color: var(--text-3); }
.rec-chip {
  display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px;
  background: #eef4ff; color: var(--blue-dk); font-size: 12px; border: 1px solid #dbe7ff;
}
.rec-chip.link { text-decoration: none; }
.rec-chip.link:hover { background: #e2ecff; }
.rec-chip.muted { background: #f2f4f8; color: var(--text-2); border-color: var(--line); }
@media (max-width: 900px) {
  .rec-audit { display: block; margin: 4px 0 0; padding-left: 0; border-left: 0; }
  .rec-targets { display: flex; }
}

/* ================= 员工姓名下拉选择器（授权管理页，主色 #4667EA） ================= */
:root { --pick: #4667EA; --pick-dk: #3a55cc; --pick-lt: #eef1fd; }
.upick { position: relative; }
.upick .upick-input { width: 100%; padding-right: 34px; background: #fff; }
.upick .upick-input::placeholder { color: var(--text-3); }
.upick .upick-input:focus,
.upick.open .upick-input {
  border-color: var(--pick); box-shadow: 0 0 0 3px rgba(70, 103, 234, .16);
}
.upick-arrow {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  display: flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 6px;
  color: var(--pick); background: var(--pick-lt); cursor: pointer;
  transition: transform .15s ease, background .15s ease;
}
.upick-arrow:hover { background: #e2e7fb; }
.upick.open .upick-arrow { transform: translateY(-50%) rotate(180deg); }
.upick-panel {
  position: absolute; z-index: 40; left: 0; right: 0; top: calc(100% + 6px);
  background: #fff; border: 1px solid #dde3f8; border-radius: 10px;
  box-shadow: 0 14px 32px rgba(31, 46, 110, .16);
  max-height: 268px; overflow-y: auto; padding: 6px;
}
.upick-item {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 9px; border-radius: 8px; cursor: pointer;
  font-size: 13px; color: var(--text); line-height: 1.4;
}
.upick-av {
  flex: none; width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--pick-lt); color: var(--pick); font-size: 12px; font-weight: 600;
}
.upick-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 仅在后端检测到「重名」时才会渲染（区分两个同名员工），常规情况不出现 */
.upick-sub {
  flex: none; max-width: 42%; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; font-size: 11.5px; color: var(--text-3);
}
.upick-item:hover .upick-sub, .upick-item.active .upick-sub { color: rgba(255, 255, 255, .82); }
.upick-item:hover, .upick-item.active { background: var(--pick); color: #fff; }
.upick-item:hover .upick-av, .upick-item.active .upick-av { background: rgba(255, 255, 255, .24); color: #fff; }
.upick-empty { padding: 12px 10px; text-align: center; font-size: 12.5px; color: var(--text-3); }
@media (max-width: 640px) { .upick-panel { max-height: 44vh; } }

/* ================= 员工名单来源（授权管理页顶部的通讯录同步条） ================= */
.roster-bar {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
}
.roster-info { flex: 1 1 320px; min-width: 0; font-size: 13.5px; line-height: 1.7; }
.roster-info strong { color: var(--pick); }
.roster-bar form { flex: none; margin: 0; }

/* ================= 管理员管理（管理员页） ================= */
.admin-add { display: flex; gap: 10px; align-items: flex-start; margin: 0 0 14px; flex-wrap: wrap; }
.admin-upick { flex: 1 1 280px; min-width: 0; }
.admin-add-btn { flex: none; white-space: nowrap; }

/* ================= 专区配置：系统自动填写的项（只展示状态，无输入框） ================= */
.autoline .autostat {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  min-height: 34px; font-size: 13px;
}
.autoline .autostat code { background: var(--pick-lt, #eef1fd); color: #3a55cc; padding: 2px 8px; border-radius: 6px; }
.autoline .autostat .autosecret { letter-spacing: 1px; }
.autoline .autostat .help { margin: 0; }

/* ================= 专区配置：回调 URL 展示（复制粘贴到企微后台） ================= */
.cburl {
  border: 1px solid var(--line); border-radius: 10px; background: #fafbfd;
  padding: 10px 12px; margin: 0 0 12px;
}
.cburl-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cburl-row + .cburl-row { margin-top: 6px; }
.cburl-tag {
  flex: none; font-size: 11.5px; font-weight: 600;
  color: var(--pick); background: var(--pick-lt); padding: 2px 8px; border-radius: 6px;
}
.cburl-val { flex: 1 1 300px; min-width: 0; word-break: break-all; color: #3a55cc; }
.cburl .help { margin: 8px 0 0; font-size: 11.5px; color: var(--text-3); line-height: 1.65; }
.cburl .help code { word-break: break-all; }
.cburl .alert { margin: 8px 0 0; }

/* 生成的 Token / AESKey 明文回显（密码框看不见，需要复制到企微后台） */
.cfgrow .genout {
  background: var(--pick-lt, #eef1fd); color: #3a55cc;
  padding: 2px 8px; border-radius: 6px; letter-spacing: .5px;
  max-width: 100%; overflow-wrap: anywhere;
}
