/* ==========================================================================
   ByteMsg Admin · 设计系统
   设计方向：克制的几何感 SaaS 工作台 — 深石板侧栏 + 浅雾内容区
   字体：Manrope（无衬线）+ JetBrains Mono（等宽）
   品牌色：#4F46E5（靛蓝）
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  /* === 品牌色 === */
  --brand-50: #EEF2FF;
  --brand-100: #E0E7FF;
  --brand-200: #C7D2FE;
  --brand-400: #818CF8;
  --brand-500: #6366F1;
  --brand-600: #4F46E5;
  --brand-700: #4338CA;
  --brand-800: #3730A3;

  /* === 中性色 === */
  --slate-25: #FCFCFD;
  --slate-50: #F8FAFC;
  --slate-100: #F1F5F9;
  --slate-150: #E8EDF3;
  --slate-200: #E2E8F0;
  --slate-300: #CBD5E1;
  --slate-400: #94A3B8;
  --slate-500: #64748B;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1E293B;
  --slate-900: #0F172A;
  --slate-950: #020617;

  /* === 语义色 === */
  --success: #10B981;
  --success-bg: #ECFDF5;
  --warning: #F59E0B;
  --warning-bg: #FFFBEB;
  --danger: #EF4444;
  --danger-bg: #FEF2F2;
  --info: #0EA5E9;
  --info-bg: #F0F9FF;

  /* === 阴影 === */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(15, 23, 42, 0.10), 0 8px 10px -6px rgba(15, 23, 42, 0.04);
  --shadow-brand: 0 8px 24px -4px rgba(79, 70, 229, 0.32);
  --shadow-inset: inset 0 1px 2px rgba(15, 23, 42, 0.04);

  /* === 几何 === */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  /* === 布局 === */
  --sidebar-w: 232px;
  --header-h: 60px;
}

/* ==========================================================================
   全局基础
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  font-feature-settings: 'cv11', 'ss01';
  font-size: 14px;
  line-height: 1.55;
  color: var(--slate-800);
  background: var(--slate-50);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

code, pre, .mono { font-family: 'JetBrains Mono', ui-monospace, monospace; }

/* 滚动条美化 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--slate-300); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--slate-400); }
::-webkit-scrollbar-track { background: transparent; }

/* ==========================================================================
   Layui 覆盖
   ========================================================================== */
.layui-btn,
.layui-input,
.layui-select,
.layui-textarea {
  font-family: inherit !important;
  border-radius: var(--radius-sm) !important;
  border-color: var(--slate-200) !important;
  transition: all 0.15s ease;
}
.layui-input:focus,
.layui-textarea:focus,
.layui-input:hover,
.layui-textarea:hover {
  border-color: var(--brand-500) !important;
  box-shadow: 0 0 0 3px var(--brand-100) !important;
}

.layui-btn {
  background: var(--slate-100);
  color: var(--slate-700);
  font-weight: 600;
  letter-spacing: -0.01em;
  height: 36px;
  line-height: 36px;
  padding: 0 16px;
}
.layui-btn-normal {
  background: var(--brand-600) !important;
  color: #fff !important;
  box-shadow: var(--shadow-brand);
}
.layui-btn-normal:hover { background: var(--brand-700) !important; }
.layui-btn-primary {
  background: #fff !important;
  border: 1px solid var(--slate-200) !important;
  color: var(--slate-700) !important;
}
.layui-btn-primary:hover {
  border-color: var(--brand-400) !important;
  color: var(--brand-700) !important;
}
.layui-btn-danger {
  background: var(--danger) !important;
  color: #fff !important;
}
.layui-btn-warm { background: var(--warning) !important; color: #fff !important; }
.layui-btn-sm { height: 28px; line-height: 28px; padding: 0 12px; font-size: 12px; }
.layui-btn-xs { height: 24px; line-height: 24px; padding: 0 10px; font-size: 12px; }

.layui-table {
  font-family: inherit !important;
  border: none !important;
}
.layui-table thead tr {
  background: var(--slate-50) !important;
}
.layui-table th {
  font-weight: 600 !important;
  font-size: 12px !important;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--slate-500) !important;
  border-bottom: 1px solid var(--slate-200) !important;
}
.layui-table td {
  border-bottom: 1px solid var(--slate-100) !important;
  color: var(--slate-700);
}

.layui-form-label {
  font-weight: 500;
  color: var(--slate-700);
}

.layui-layer-title {
  font-weight: 700 !important;
  color: var(--slate-900) !important;
  background: #fff !important;
  border-bottom: 1px solid var(--slate-100) !important;
}
.layui-layer { border-radius: var(--radius-lg) !important; box-shadow: var(--shadow-xl) !important; }
.layui-layer-btn { border-top: 1px solid var(--slate-100) !important; }

.layui-form-switch {
  border-radius: 999px !important;
}

/* ==========================================================================
   通用组件
   ========================================================================== */
.bm-card {
  background: #fff;
  border: 1px solid var(--slate-150);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.bm-page {
  padding: 24px 28px;
  min-height: 100vh;
  background: var(--slate-50);
}
.bm-page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--slate-150);
}
.bm-page-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--slate-900);
  margin: 0 0 4px;
}
.bm-page-sub {
  font-size: 13px;
  color: var(--slate-500);
  margin: 0;
}

.bm-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--slate-100);
  color: var(--slate-700);
}
.bm-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--slate-400);
}
.bm-badge.is-online { background: var(--success-bg); color: var(--success); }
.bm-badge.is-online::before { background: var(--success); box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18); }
.bm-badge.is-busy { background: var(--warning-bg); color: var(--warning); }
.bm-badge.is-busy::before { background: var(--warning); }
.bm-badge.is-offline { background: var(--slate-100); color: var(--slate-500); }

.bm-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--slate-400);
}
.bm-empty-icon {
  font-size: 48px;
  color: var(--slate-200);
  margin-bottom: 12px;
}
.bm-empty-text { font-size: 13px; }

/* ==========================================================================
   登录页
   ========================================================================== */
.bm-login {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--slate-50);
  position: relative;
  overflow: hidden;
}
.bm-login::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 80%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(99, 102, 241, 0.05) 0%, transparent 50%);
  pointer-events: none;
}

.bm-login-art {
  position: relative;
  background: linear-gradient(135deg, var(--slate-900) 0%, var(--slate-800) 100%);
  color: #fff;
  padding: 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}
.bm-login-art::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 30% 20%, rgba(99, 102, 241, 0.45) 0%, transparent 45%),
    radial-gradient(circle at 70% 80%, rgba(79, 70, 229, 0.35) 0%, transparent 50%);
  filter: blur(40px);
}
.bm-login-art::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence baseFrequency='0.85'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.06 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
  opacity: 0.6;
  pointer-events: none;
}
.bm-login-brand {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.bm-login-brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 16px;
  box-shadow: var(--shadow-brand);
}
.bm-login-hero {
  position: relative;
  z-index: 1;
}
.bm-login-eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--brand-400);
  margin-bottom: 16px;
}
.bm-login-headline {
  font-size: 44px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.03em;
  margin: 0 0 20px;
}
.bm-login-headline em {
  font-style: italic;
  font-weight: 400;
  color: var(--brand-400);
}
.bm-login-desc {
  font-size: 15px;
  color: var(--slate-300);
  line-height: 1.7;
  max-width: 420px;
}
.bm-login-meta {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 32px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--slate-400);
  letter-spacing: 0.05em;
}
.bm-login-meta strong { color: #fff; font-weight: 500; display: block; margin-bottom: 4px; font-size: 18px; font-family: 'Manrope', sans-serif; letter-spacing: -0.01em; }

.bm-login-form-wrap {
  display: grid;
  place-items: center;
  padding: 56px;
  position: relative;
  z-index: 1;
}
.bm-login-form {
  width: 100%;
  max-width: 380px;
}
.bm-login-form-title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--slate-900);
  margin: 0 0 8px;
}
.bm-login-form-sub {
  font-size: 14px;
  color: var(--slate-500);
  margin: 0 0 36px;
}
.bm-field { margin-bottom: 18px; }
.bm-field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--slate-700);
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}
.bm-field-input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  background: #fff;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 14px;
  color: var(--slate-900);
  transition: all 0.15s ease;
  box-shadow: var(--shadow-inset);
}
.bm-field-input:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px var(--brand-100);
}
.bm-btn-primary {
  width: 100%;
  height: 46px;
  background: var(--brand-600);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: var(--shadow-brand);
  transition: all 0.15s ease;
  margin-top: 12px;
}
.bm-btn-primary:hover { background: var(--brand-700); transform: translateY(-1px); }
.bm-btn-primary:active { transform: translateY(0); }
.bm-btn-primary:disabled { background: var(--slate-300); box-shadow: none; cursor: not-allowed; transform: none; }

.bm-login-foot {
  margin-top: 28px;
  font-size: 12px;
  color: var(--slate-400);
  text-align: center;
}
.bm-login-foot a { color: var(--brand-600); text-decoration: none; font-weight: 600; }

@media (max-width: 900px) {
  .bm-login { grid-template-columns: 1fr; }
  .bm-login-art { display: none; }
}

/* ==========================================================================
   主框架（index.html）
   ========================================================================== */
.bm-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--header-h) 1fr;
  height: 100vh;
}
.bm-header {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: #fff;
  border-bottom: 1px solid var(--slate-150);
  z-index: 10;
}
.bm-header-crumb {
  font-size: 13px;
  color: var(--slate-500);
}
.bm-header-crumb strong { color: var(--slate-900); font-weight: 600; }
.bm-header-tools { display: flex; align-items: center; gap: 16px; }
.bm-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 6px 6px;
  border-radius: 999px;
  background: var(--slate-50);
  border: 1px solid var(--slate-150);
  cursor: pointer;
  transition: all 0.15s ease;
}
.bm-user:hover { background: #fff; border-color: var(--slate-200); box-shadow: var(--shadow-sm); }
.bm-user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 12px;
}
.bm-user-name { font-size: 13px; font-weight: 600; color: var(--slate-800); }
.bm-user-role {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--slate-500);
  letter-spacing: 0.05em;
}
.bm-icon-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--slate-500);
  transition: all 0.15s ease;
  background: transparent;
  border: none;
  font-size: 16px;
}
.bm-icon-btn:hover { background: var(--slate-100); color: var(--slate-800); }

/* 侧边栏 */
.bm-sidebar {
  grid-column: 1;
  grid-row: 1 / 3;
  background: var(--slate-900);
  color: var(--slate-300);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}
.bm-sidebar::before {
  content: '';
  position: absolute;
  top: -100px;
  left: -100px;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.18) 0%, transparent 70%);
  pointer-events: none;
}
.bm-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 22px;
  position: relative;
}
.bm-sidebar-brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
}
.bm-sidebar-brand-text {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #fff;
}
.bm-sidebar-brand-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  letter-spacing: 0.15em;
  color: var(--brand-400);
  text-transform: uppercase;
  margin-top: 2px;
}
.bm-sidebar-section {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--slate-500);
  padding: 16px 12px 8px;
}
.bm-nav { list-style: none; padding: 0; margin: 0; position: relative; }
.bm-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--slate-400);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s ease;
  position: relative;
  text-decoration: none;
}
.bm-nav-item:hover { background: rgba(255, 255, 255, 0.04); color: #fff; }
.bm-nav-item.is-active {
  background: linear-gradient(90deg, rgba(99, 102, 241, 0.18), rgba(99, 102, 241, 0.04));
  color: #fff;
}
.bm-nav-item.is-active::before {
  content: '';
  position: absolute;
  left: -14px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--brand-500);
}
.bm-nav-icon { font-size: 16px; width: 18px; text-align: center; opacity: 0.85; }
.bm-nav-badge {
  margin-left: auto;
  background: var(--brand-600);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  min-width: 18px;
  text-align: center;
}

.bm-sidebar-foot {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--slate-600);
  letter-spacing: 0.05em;
}
.bm-sidebar-foot strong { color: var(--slate-400); font-weight: 500; }

/* 主内容 iframe */
.bm-main {
  grid-column: 2;
  grid-row: 2;
  background: var(--slate-50);
  overflow: hidden;
}
.bm-main iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}


/* ==========================================================================
   工作台（workspace.html）
   ========================================================================== */
.bm-ws {
  display: grid;
  grid-template-columns: minmax(300px, 32%) 1fr;
  grid-template-rows: 100vh;          /* 锁定行高，避免内容撑开导致整体滚动 */
  height: 100vh;
  overflow: hidden;                    /* 阻止外层滚动条 */
  background: var(--slate-50);
}

/* 左栏：会话列表 */
.bm-ws-left {
  background: #fff;
  border-right: 1px solid var(--slate-150);
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;                       /* 关键：grid 子项默认 min-height:auto */
  overflow: hidden;
}
.bm-ws-left-head {
  padding: 18px 20px 0;
}
.bm-ws-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--slate-900);
  margin: 0 0 4px;
}
.bm-ws-conn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--slate-500);
  letter-spacing: 0.05em;
  margin-bottom: 14px;
}
.bm-ws-conn-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--slate-400);
  animation: pulse 2s infinite;
}
.bm-ws-conn.is-connected .bm-ws-conn-dot { background: var(--success); box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18); }
.bm-ws-conn.is-error .bm-ws-conn-dot { background: var(--danger); }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.bm-ws-tabs {
  display: flex;
  gap: 4px;
  padding: 0 20px 12px;
  border-bottom: 1px solid var(--slate-100);
}
.bm-ws-tab {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  color: var(--slate-500);
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  font-family: inherit;
}
.bm-ws-tab:hover { color: var(--slate-800); background: var(--slate-50); }
.bm-ws-tab.is-active { background: var(--brand-50); color: var(--brand-700); }
.bm-ws-tab-count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  background: rgba(0, 0, 0, 0.06);
  padding: 1px 6px;
  border-radius: 999px;
  font-weight: 600;
}
.bm-ws-tab.is-active .bm-ws-tab-count { background: var(--brand-200); color: var(--brand-700); }

.bm-conv-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}
.bm-conv-item {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s ease;
  margin-bottom: 4px;
  position: relative;
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 12px;
  align-items: center;
}
.bm-conv-item:hover { background: var(--slate-50); }
.bm-conv-item.is-active {
  background: var(--brand-50);
  box-shadow: inset 0 0 0 1px var(--brand-200);
}
.bm-conv-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--slate-200), var(--slate-300));
  color: var(--slate-700);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
  position: relative;
  flex-shrink: 0;
}
.bm-conv-item.is-pending .bm-conv-avatar {
  background: linear-gradient(135deg, #FEF3C7, #FDE68A);
  color: var(--warning);
}
.bm-conv-avatar.has-online::after {
  content: '';
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--success);
  border: 2px solid #fff;
}
.bm-conv-body { min-width: 0; }
.bm-conv-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}
.bm-conv-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--slate-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bm-conv-time {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--slate-400);
  flex-shrink: 0;
}
.bm-conv-preview {
  font-size: 12px;
  color: var(--slate-500);
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bm-conv-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
}
.bm-conv-unread {
  background: var(--brand-600);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  min-width: 16px;
  text-align: center;
}
.bm-conv-accept {
  margin-left: auto;
  height: 26px;
  padding: 0 12px;
  background: var(--brand-600);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: var(--shadow-brand);
  transition: all 0.15s ease;
}
.bm-conv-accept:hover { background: var(--brand-700); }

/* 右栏：聊天区 */
.bm-ws-right {
  display: flex;
  flex-direction: column;
  background: var(--slate-50);
  min-width: 0;
  min-height: 0;                       /* 关键：阻止 grid 子项被内容撑开 */
  height: 100%;
  overflow: hidden;                    /* 关键：自身不滚，由内部消息区独立滚动 */
}
.bm-chat-head {
  padding: 16px 24px;
  background: #fff;
  border-bottom: 1px solid var(--slate-150);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}
.bm-chat-head-info { display: flex; align-items: center; gap: 14px; min-width: 0; }
.bm-chat-head-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
}
.bm-chat-head-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--slate-900);
  letter-spacing: -0.01em;
}
.bm-chat-head-meta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--slate-500);
  margin-top: 2px;
}
.bm-chat-head-meta span { margin-right: 14px; }
.bm-chat-head-tools { display: flex; gap: 8px; }

.bm-chat-msgs {
  flex: 1 1 0%;
  min-height: 0;
  overflow-y: auto;
  padding: 28px 32px;
  background:
    linear-gradient(var(--slate-50), var(--slate-50)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4'%3E%3Crect fill='%23E2E8F0' width='1' height='1'/%3E%3C/svg%3E");
  background-size: auto, 16px 16px;
  background-blend-mode: multiply;
}
.bm-chat-day {
  text-align: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--slate-400);
  margin: 16px 0;
  letter-spacing: 0.05em;
}
.bm-chat-day::before, .bm-chat-day::after {
  content: '———';
  margin: 0 10px;
  opacity: 0.4;
}

.bm-msg {
  display: flex;
  margin-bottom: 14px;
  align-items: flex-end;
  gap: 10px;
}
.bm-msg-avatar {
  width: 36px !important;
  height: 36px !important;
  min-width: 36px !important;
  max-width: 36px !important;
  min-height: 36px !important;
  max-height: 36px !important;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--slate-300), var(--slate-400));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0 !important;
  overflow: hidden !important;
  box-sizing: border-box;
}
.bm-msg-avatar img {
  width: 36px !important;
  height: 36px !important;
  max-width: 36px !important;
  max-height: 36px !important;
  min-width: 36px !important;
  min-height: 36px !important;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  box-sizing: border-box;
}
.bm-msg-body {
  flex: 1 1 auto;            /* 关键：填满主轴剩余空间，避免被收缩成最小内容宽度 */
  min-width: 0;
  max-width: calc(100% - 42px);
  text-align: left;
}
.bm-msg.is-agent .bm-msg-body { text-align: right; }
.bm-msg-bubble {
  display: inline-block;
  vertical-align: top;
  min-width: 0;              /* 不强制最小宽度，避免触发奇异的换行约束 */
  max-width: 75%;            /* 单条气泡最多占消息行宽度的 75% */
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.55;
  /* 中文需要按词不拆字：break-word 在 CJK 下会按字符断行，禁用 */
  word-break: normal;
  overflow-wrap: anywhere;   /* 仅在内容真的溢出时（如长 URL）才断行 */
  white-space: pre-wrap;
  text-align: left;
  position: relative;
  box-shadow: var(--shadow-xs);
  width: -moz-fit-content;
  width: fit-content;        /* 配合 inline-block，强制按内容宽度 */
}
.bm-msg-time {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--slate-400);
  margin: 4px 0 0;
}

/* 访客（左侧） */
.bm-msg.is-visitor .bm-msg-bubble {
  background: #fff;
  border: 1px solid var(--slate-150);
  color: var(--slate-800);
  border-bottom-left-radius: 4px;
}

/* 客服（右侧） */
.bm-msg.is-agent {
  flex-direction: row-reverse;
}
.bm-msg.is-agent .bm-msg-bubble {
  background: linear-gradient(135deg, var(--brand-600), var(--brand-700));
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 14px -4px rgba(79, 70, 229, 0.4);
}
.bm-msg.is-agent .bm-msg-avatar {
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
}
.bm-msg.is-agent .bm-msg-time { text-align: right; }

/* 系统消息 */
.bm-msg.is-system {
  justify-content: center;
}
.bm-msg.is-system .bm-msg-avatar { display: none; }
.bm-msg.is-system .bm-msg-bubble {
  background: transparent;
  color: var(--slate-400);
  font-size: 12px;
  text-align: center;
  font-style: italic;
  box-shadow: none;
  padding: 4px 12px;
  border: 1px dashed var(--slate-200);
  border-radius: 999px;
}

/* 图片气泡 */
.bm-msg-bubble.is-image {
  padding: 4px !important;
  background: transparent !important;
  box-shadow: none !important;
  border: none !important;
}
.bm-msg-bubble img,
.bm-msg-image {
  display: block;
  max-width: 300px;
  max-height: 300px;
  width: auto;
  height: auto;
  border-radius: 8px;
  cursor: pointer;
  object-fit: contain;
  background: var(--slate-50);
  border: 1px solid var(--slate-150);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.bm-msg-bubble img:hover,
.bm-msg-image:hover {
  transform: scale(1.01);
  box-shadow: var(--shadow-md);
}
.bm-msg.is-agent .bm-msg-bubble.is-image {
  background: transparent !important;
}

/* 输入区 */
.bm-chat-input {
  background: #fff;
  border-top: 1px solid var(--slate-150);
  padding: 12px 24px 16px;
  flex-shrink: 0;
}
.bm-chat-toolbar {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
}
.bm-tool-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--slate-500);
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 16px;
  position: relative;
}
.bm-tool-btn:hover { background: var(--slate-100); color: var(--brand-600); }

.bm-chat-textarea {
  width: 100%;
  min-height: 60px;
  max-height: 160px;
  padding: 8px 0;
  border: none;
  resize: none;
  font-family: inherit;
  font-size: 14px;
  color: var(--slate-900);
  outline: none;
  line-height: 1.6;
}
.bm-chat-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 8px;
  border-top: 1px solid var(--slate-100);
}
.bm-chat-hint {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--slate-400);
  letter-spacing: 0.04em;
}
.bm-chat-hint kbd {
  padding: 1px 5px;
  background: var(--slate-100);
  border: 1px solid var(--slate-200);
  border-radius: 3px;
  font-family: inherit;
  font-size: 10px;
  color: var(--slate-700);
  margin: 0 2px;
}
.bm-chat-send {
  height: 32px;
  padding: 0 18px;
  background: var(--brand-600);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-brand);
  transition: all 0.15s ease;
}
.bm-chat-send:hover { background: var(--brand-700); }
.bm-chat-send:disabled {
  background: var(--slate-200);
  color: var(--slate-400);
  box-shadow: none;
  cursor: not-allowed;
}

/* 空态 */
.bm-chat-empty {
  flex: 1;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--slate-400);
}
.bm-chat-empty-icon {
  font-size: 64px;
  color: var(--slate-200);
  margin-bottom: 16px;
}
.bm-chat-empty-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--slate-600);
  margin: 0 0 6px;
}
.bm-chat-empty-text { font-size: 13px; max-width: 320px; }

/* 快捷回复浮层 */
.bm-qr-popup {
  position: absolute;
  bottom: 100%;
  left: 0;
  margin-bottom: 8px;
  width: 320px;
  max-height: 280px;
  background: #fff;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  display: none;
  flex-direction: column;
  z-index: 5;
}
.bm-qr-popup.is-open { display: flex; }
.bm-qr-popup-head {
  padding: 10px 14px;
  border-bottom: 1px solid var(--slate-100);
  font-size: 12px;
  font-weight: 600;
  color: var(--slate-700);
}
.bm-qr-popup-list {
  overflow-y: auto;
  padding: 6px;
}
.bm-qr-popup-item {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.1s ease;
}
.bm-qr-popup-item:hover { background: var(--brand-50); }
.bm-qr-popup-shortcut {
  display: inline-block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  background: var(--slate-100);
  color: var(--brand-700);
  padding: 1px 6px;
  border-radius: 3px;
  margin-bottom: 3px;
}
.bm-qr-popup-content {
  font-size: 12px;
  color: var(--slate-700);
  line-height: 1.4;
}

/* ==========================================================================
   坐席管理
   ========================================================================== */
.bm-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.bm-stat {
  background: #fff;
  border: 1px solid var(--slate-150);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}
.bm-stat::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 60px;
  height: 60px;
  background: radial-gradient(circle, var(--brand-100) 0%, transparent 70%);
  opacity: 0.6;
}
.bm-stat-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--slate-500);
  margin: 0 0 8px;
}
.bm-stat-value {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--slate-900);
  line-height: 1.1;
}
.bm-stat-trend {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  margin-top: 6px;
}
.bm-stat-trend.is-up { color: var(--success); }
.bm-stat-trend.is-down { color: var(--danger); }

.bm-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 12px;
}
.bm-toolbar-left { display: flex; gap: 8px; align-items: center; }
.bm-toolbar-right { display: flex; gap: 8px; align-items: center; }

.bm-table-wrap {
  background: #fff;
  border: 1px solid var(--slate-150);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.bm-table-wrap .layui-table { margin: 0 !important; }

/* 表格行高与单元格内边距：适配头像/进度条等富内容 */
.bm-table-wrap .layui-table tbody tr {
  height: 60px;
}
.bm-table-wrap .layui-table tbody td {
  padding: 12px 8px !important;
  vertical-align: middle !important;
  height: 60px;
}
.bm-table-wrap .layui-table-cell {
  height: auto !important;
  min-height: 36px;
  line-height: 1.55 !important;
  padding: 0 8px !important;
  display: flex;
  align-items: center;
}
.bm-table-wrap .layui-table-view .layui-table tbody tr {
  height: 60px;
}
.bm-table-wrap .layui-table-view .layui-table-body td {
  padding: 12px 0 !important;
  vertical-align: middle !important;
}
/* 表头保持紧凑 */
.bm-table-wrap .layui-table-view .layui-table-header th .layui-table-cell {
  min-height: auto;
  align-items: center;
}

/* ==========================================================================
   快捷回复
   ========================================================================== */
.bm-qr {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 20px;
  align-items: start;
}
.bm-qr-cats {
  background: #fff;
  border: 1px solid var(--slate-150);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.bm-qr-cats-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--slate-100);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.bm-qr-cats-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--slate-900);
}
.bm-qr-cat-list { padding: 6px; }
.bm-qr-cat-item {
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  color: var(--slate-700);
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2px;
  transition: all 0.15s ease;
}
.bm-qr-cat-item:hover { background: var(--slate-50); }
.bm-qr-cat-item.is-active { background: var(--brand-50); color: var(--brand-700); font-weight: 600; }
.bm-qr-cat-count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--slate-400);
}
.bm-qr-cat-item.is-active .bm-qr-cat-count { color: var(--brand-600); }

.bm-qr-list {
  background: #fff;
  border: 1px solid var(--slate-150);
  border-radius: var(--radius-lg);
  padding: 8px;
  min-height: 400px;
}
.bm-qr-row {
  display: grid;
  grid-template-columns: 130px 1fr auto;
  gap: 16px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  align-items: center;
  transition: all 0.15s ease;
  border-bottom: 1px solid var(--slate-100);
}
.bm-qr-row:last-child { border-bottom: none; }
.bm-qr-row:hover { background: var(--slate-50); }
.bm-qr-shortcut {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 600;
  color: var(--brand-700);
  background: var(--brand-50);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  display: inline-block;
  width: fit-content;
}
.bm-qr-content {
  color: var(--slate-700);
  line-height: 1.5;
  font-size: 13px;
}
.bm-qr-actions { display: flex; gap: 6px; }

/* ==========================================================================
   应用设置
   ========================================================================== */
.bm-settings-grid {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 24px;
  align-items: start;
}
@media (max-width: 1100px) {
  .bm-settings-grid { grid-template-columns: 1fr; }
}

.bm-section {
  background: #fff;
  border: 1px solid var(--slate-150);
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  margin-bottom: 16px;
}
.bm-section-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--slate-900);
  margin: 0 0 4px;
}
.bm-section-sub {
  font-size: 12px;
  color: var(--slate-500);
  margin: 0 0 18px;
}

.bm-key-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--slate-50);
  border: 1px solid var(--slate-150);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--slate-700);
  margin-bottom: 8px;
}
.bm-key-label {
  font-family: 'Manrope', sans-serif;
  font-size: 11px;
  font-weight: 600;
  color: var(--slate-500);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-right: 6px;
}
.bm-key-value {
  flex: 1;
  word-break: break-all;
  user-select: all;
}
.bm-key-actions { display: flex; gap: 4px; }

.bm-snippet {
  background: var(--slate-900);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  position: relative;
  overflow: hidden;
}
.bm-snippet::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--brand-500), transparent);
}
.bm-snippet pre {
  margin: 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  line-height: 1.7;
  color: #E2E8F0;
  white-space: pre;
  overflow-x: auto;
}
.bm-snippet pre .tk { color: #93C5FD; }
.bm-snippet pre .ts { color: #FCA5A5; }
.bm-snippet pre .tc { color: #6B7280; font-style: italic; }
.bm-snippet-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.bm-snippet-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.15em;
  color: var(--slate-500);
  text-transform: uppercase;
}
.bm-snippet-copy {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.bm-snippet-copy:hover { background: rgba(255, 255, 255, 0.12); }

/* 表单 */
.bm-form-row { margin-bottom: 18px; }
.bm-form-row label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--slate-700);
  margin-bottom: 6px;
}
.bm-form-row input,
.bm-form-row select,
.bm-form-row textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  color: var(--slate-900);
  background: #fff;
  transition: all 0.15s ease;
}
.bm-form-row input:focus,
.bm-form-row select:focus,
.bm-form-row textarea:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px var(--brand-100);
}
.bm-form-row textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
.bm-form-help { font-size: 11px; color: var(--slate-500); margin-top: 4px; }

.bm-form-actions {
  display: flex;
  gap: 10px;
  padding-top: 18px;
  border-top: 1px solid var(--slate-100);
  margin-top: 24px;
}

/* 动画 */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.bm-anim { animation: fadeInUp 0.3s ease both; }

/* ==========================================================================
   断线重连横幅
   ========================================================================== */
.bm-reconnect-bar {
  position: fixed; top: 0; left: 0; right: 0;
  padding: 8px 16px; text-align: center; font-size: 13px;
  z-index: 9999; transition: all 0.3s;
  font-weight: 500;
}
.bm-reconnect-bar.disconnected { background: #FEE2E2; color: #DC2626; }
.bm-reconnect-bar.reconnected { background: #D1FAE5; color: #059669; }

/* ==========================================================================
   未读消息角标
   ========================================================================== */
.bm-badge-unread {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  background: #EF4444; color: #fff; border-radius: 9px;
  font-size: 11px; font-weight: 600;
}

/* ==========================================================================
   正在输入指示器
   ========================================================================== */
.bm-typing-indicator {
  display: flex; align-items: center; gap: 4px;
  padding: 8px 12px; color: #6B7280; font-size: 13px;
  flex-shrink: 0;
}
.bm-typing-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: #9CA3AF; animation: bm-typing 1.4s infinite;
}
.bm-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.bm-typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes bm-typing {
  0%, 60%, 100% { opacity: 0.4; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-4px); }
}
.bm-typing-text { margin-left: 6px; }

/* ==========================================================================
   消息搜索 UI
   ========================================================================== */
.bm-search-toggle {
  background: none; border: none; cursor: pointer;
  color: var(--slate-500); font-size: 18px; padding: 4px 8px;
  border-radius: var(--radius-sm); transition: background 0.15s;
}
.bm-search-toggle:hover { background: var(--slate-100); color: var(--slate-700); }

/* 拉黑IP按钮：复用 search-toggle 外型 + 警示色 */
.bm-search-toggle.bm-block-ip { color: var(--danger); }
.bm-search-toggle.bm-block-ip:hover { background: var(--danger-bg); color: var(--danger); }
.bm-search-toggle.bm-block-ip.is-blocked { color: var(--slate-400); cursor: not-allowed; }
.bm-search-toggle.bm-block-ip.is-blocked:hover { background: none; color: var(--slate-400); }

.bm-search-overlay {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  background: var(--slate-25); z-index: 50;
  display: flex; flex-direction: column;
}
.bm-search-header {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px; border-bottom: 1px solid var(--slate-150);
}
.bm-search-input {
  flex: 1; border: 1px solid var(--slate-200); border-radius: var(--radius-sm);
  padding: 8px 12px; font-size: 14px; outline: none;
  transition: border-color 0.15s;
}
.bm-search-input:focus { border-color: var(--brand-500); }
.bm-search-close {
  background: none; border: none; cursor: pointer;
  color: var(--slate-400); font-size: 20px; padding: 4px;
}
.bm-search-close:hover { color: var(--slate-700); }
.bm-search-results {
  flex: 1; overflow-y: auto; padding: 8px 0;
}
.bm-search-item {
  padding: 10px 16px; cursor: pointer;
  border-bottom: 1px solid var(--slate-100);
  transition: background 0.1s;
}
.bm-search-item:hover { background: var(--slate-50); }
.bm-search-item-meta {
  font-size: 11px; color: var(--slate-400); margin-bottom: 4px;
}
.bm-search-item-content {
  font-size: 13px; color: var(--slate-700); line-height: 1.5;
}
.bm-search-item-content mark {
  background: #FDE68A; color: inherit; border-radius: 2px; padding: 0 1px;
}
.bm-search-empty {
  padding: 40px 20px; text-align: center; color: var(--slate-400); font-size: 13px;
}
