/* 火灵CRM 悬浮 AI 助手（桌面 + 手机） */
#hl-ai-fab {
  position: fixed;
  right: 18px;
  bottom: 78px;
  z-index: 12001;
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1d4ed8 0%, #06b6d4 100%);
  box-shadow: 0 12px 28px rgba(6, 182, 212, .32), 0 4px 10px rgba(15, 23, 42, .2);
  transition: transform .16s ease, box-shadow .16s ease;
}
#hl-ai-fab:hover { transform: translateY(-2px); box-shadow: 0 16px 34px rgba(6, 182, 212, .4); }
#hl-ai-fab:active { transform: translateY(0); }
#hl-ai-fab svg { width: 26px; height: 26px; }
#hl-ai-fab .hl-ai-pulse {
  position: absolute; right: 3px; top: 3px; width: 10px; height: 10px; border-radius: 50%;
  background: #22c55e; border: 2px solid #fff;
}
#hl-ai-panel {
  position: fixed;
  right: 18px;
  bottom: 146px;
  z-index: 12000;
  width: 390px;
  height: min(620px, calc(100vh - 130px));
  display: none;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 18px;
  box-shadow: 0 26px 70px rgba(15, 23, 42, .3);
}
#hl-ai-panel.open { display: flex; }
body.hl-ai-open #hl-ai-fab { display: none; }
.hl-ai-head {
  display: flex; align-items: center; gap: 10px; padding: 13px 14px;
  color: #fff; background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 65%, #0e7490 100%);
  flex: 0 0 auto;
}
.hl-ai-avatar {
  width: 34px; height: 34px; border-radius: 11px; background: linear-gradient(135deg, #38bdf8, #06b6d4);
  display: grid; place-items: center; font-weight: 800; font-size: 15px; color: #fff; flex: 0 0 34px;
}
.hl-ai-title { min-width: 0; flex: 1; }
.hl-ai-title b { display: block; font-size: 13.5px; letter-spacing: .3px; }
.hl-ai-title span { display: block; margin-top: 2px; font-size: 10.5px; color: #a5f3fc; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hl-ai-head-btn {
  width: 28px; height: 28px; border: 0; border-radius: 8px; background: rgba(255,255,255,.12);
  color: #e2e8f0; cursor: pointer; font-size: 15px; line-height: 1; flex: 0 0 28px;
}
.hl-ai-head-btn:hover { background: rgba(255,255,255,.22); }
.hl-ai-body {
  flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain;
  padding: 14px 13px 10px; background: #f8fafc; scroll-behavior: smooth;
}
.hl-ai-msg { display: flex; gap: 8px; margin: 0 0 12px; align-items: flex-start; }
.hl-ai-msg .hl-ai-bubble {
  max-width: calc(100% - 36px); padding: 9px 11px; border-radius: 12px;
  font-size: 12.5px; line-height: 1.65; white-space: pre-wrap; word-break: break-word;
}
.hl-ai-msg.bot .hl-ai-bubble { background: #fff; border: 1px solid #e2e8f0; color: #1e293b; border-top-left-radius: 4px; }
.hl-ai-msg.user { justify-content: flex-end; }
.hl-ai-msg.user .hl-ai-bubble { background: #2563eb; color: #fff; border-top-right-radius: 4px; }
.hl-ai-msg .hl-ai-mini {
  width: 26px; height: 26px; flex: 0 0 26px; border-radius: 8px; display: grid; place-items: center;
  background: #e0f2fe; color: #0369a1; font-size: 11px; font-weight: 800;
}
.hl-ai-msg.user .hl-ai-mini { display: none; }
.hl-ai-bubble b { font-weight: 700; }
.hl-ai-bubble code { background: #f1f5f9; color: #0f766e; padding: 0 3px; border-radius: 3px; font-size: 11.5px; }
.hl-ai-typing { display: inline-flex; gap: 3px; align-items: center; height: 18px; }
.hl-ai-typing i { width: 5px; height: 5px; border-radius: 50%; background: #64748b; animation: hl-ai-bounce 1.1s infinite; }
.hl-ai-typing i:nth-child(2) { animation-delay: .15s; }
.hl-ai-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes hl-ai-bounce { 0%,60%,100% { transform: translateY(0); opacity: .45; } 30% { transform: translateY(-4px); opacity: 1; } }
.hl-ai-quick { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 13px 10px; background: #f8fafc; }
.hl-ai-quick button {
  border: 1px solid #bae6fd; background: #fff; color: #0369a1; border-radius: 999px;
  padding: 5px 9px; font-size: 10.5px; cursor: pointer; white-space: nowrap;
}
.hl-ai-quick button:hover { background: #ecfeff; }
.hl-ai-foot { flex: 0 0 auto; padding: 9px 11px calc(9px + env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid #e2e8f0; }
.hl-ai-input-row { display: flex; align-items: flex-end; gap: 8px; }
#hl-ai-input {
  flex: 1; resize: none; max-height: 110px; min-height: 38px; border: 1px solid #cbd5e1;
  border-radius: 11px; padding: 9px 10px; font: 12.5px/1.5 -apple-system,BlinkMacSystemFont,"Segoe UI","Microsoft YaHei",sans-serif;
  color: #0f172a; outline: none; background: #fff;
}
#hl-ai-input:focus { border-color: #06b6d4; box-shadow: 0 0 0 3px rgba(6,182,212,.12); }
#hl-ai-send {
  width: 40px; height: 40px; flex: 0 0 40px; border: 0; border-radius: 11px; color: #fff;
  background: linear-gradient(135deg,#1d4ed8,#06b6d4); cursor: pointer; font-size: 17px;
}
#hl-ai-send:disabled { opacity: .45; cursor: default; }
.hl-ai-note { margin: 6px 2px 0; color: #94a3b8; font-size: 9.5px; line-height: 1.45; }
.hl-ai-offline { padding: 10px 12px; margin: 0 0 12px; border-radius: 9px; background: #fffbeb; border: 1px solid #fde68a; color: #92400e; font-size: 11px; line-height: 1.6; }

/* 数据结果 / 新增确认卡片 */
.hl-ai-data {
  margin: 0 0 12px 34px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(15,23,42,.04);
}
.hl-ai-data-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 10px; background: #f8fafc; border-bottom: 1px solid #eef2f7;
  font-size: 11.5px; font-weight: 700; color: #334155;
}
.hl-ai-data-head a { color: #0284c7; text-decoration: none; font-weight: 500; font-size: 10.5px; white-space: nowrap; }
.hl-ai-data-scroll { overflow-x: auto; max-height: 220px; overflow-y: auto; }
.hl-ai-data table { border-collapse: collapse; width: 100%; min-width: 480px; font-size: 10.5px; }
.hl-ai-data th { text-align: left; padding: 6px 8px; background: #f1f5f9; color: #64748b; font-weight: 600; white-space: nowrap; position: sticky; top: 0; }
.hl-ai-data td { padding: 6px 8px; border-top: 1px solid #f1f5f9; color: #334155; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hl-ai-data td:first-child { color: #0f172a; font-weight: 600; }
.hl-ai-metric {
  margin: 0 0 12px 34px; padding: 10px 12px; border-radius: 11px;
  background: linear-gradient(135deg,#eff6ff,#ecfeff); border: 1px solid #bae6fd;
  display: flex; align-items: baseline; gap: 8px;
}
.hl-ai-metric b { font-size: 20px; color: #0369a1; }
.hl-ai-metric span { font-size: 10.5px; color: #64748b; }
.hl-ai-action {
  margin: 0 0 12px 34px; border: 1px solid #a5f3fc; border-radius: 12px;
  background: #f0fdff; overflow: hidden;
}
.hl-ai-action-head { padding: 8px 11px; background: #e0f2fe; color: #075985; font-size: 11.5px; font-weight: 700; }
.hl-ai-action-fields { padding: 9px 11px; display: grid; grid-template-columns: auto 1fr; gap: 5px 10px; font-size: 11px; }
.hl-ai-action-fields dt { color: #64748b; }
.hl-ai-action-fields dd { margin: 0; color: #0f172a; word-break: break-word; }
.hl-ai-action-tip { padding: 0 11px 8px; font-size: 9.5px; color: #b45309; }
.hl-ai-action-btns { display: flex; gap: 7px; padding: 8px 11px 10px; }
.hl-ai-action-btns button {
  border: 1px solid #cbd5e1; background: #fff; color: #475569; border-radius: 8px;
  padding: 5px 11px; font-size: 11px; cursor: pointer;
}
.hl-ai-action-btns button.primary { background: #0891b2; border-color: #0891b2; color: #fff; font-weight: 600; }
.hl-ai-action-btns button:disabled { opacity: .5; cursor: default; }
.hl-ai-action-done { padding: 8px 11px 10px; color: #15803d; font-size: 11px; font-weight: 600; }
.hl-ai-action-err { padding: 0 11px 8px; color: #b91c1c; font-size: 10.5px; }

@media (max-width: 820px) {
  #hl-ai-fab { right: 14px; bottom: calc(76px + env(safe-area-inset-bottom)); width: 50px; height: 50px; }
  #hl-ai-fab svg { width: 23px; height: 23px; }
  #hl-ai-panel {
    left: 0; right: 0; bottom: 0; width: 100%; height: min(86vh, 720px);
    border-radius: 18px 18px 0 0; border-bottom: 0;
  }
  .hl-ai-head { padding-top: calc(13px + env(safe-area-inset-top)); }
  .hl-ai-body { padding-bottom: 8px; }
  body.hl-ai-open { overflow: hidden; }
  .hl-ai-data, .hl-ai-metric, .hl-ai-action { margin-left: 0; }
  .hl-ai-data table { min-width: 430px; }
  .hl-ai-action-fields { font-size: 11.5px; }
}

#hl-ai-attach {
  width: 36px; height: 38px; flex: 0 0 36px; border: 1px solid #cbd5e1; border-radius: 10px;
  background: #f8fafc; color: #475569; cursor: pointer; font-size: 16px;
  display: inline-flex; align-items: center; justify-content: center;
}
#hl-ai-attach:hover { background: #ecfeff; border-color: #67e8f9; }
.hl-ai-files { display: none; flex-wrap: wrap; gap: 5px; padding: 0 0 7px; }
.hl-ai-file-chip, .hl-ai-action-files span {
  display: inline-flex; align-items: center; gap: 4px; max-width: 100%;
  padding: 3px 7px; border-radius: 7px; background: #ecfeff; border: 1px solid #a5f3fc;
  color: #0e7490; font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.hl-ai-file-chip button { border: 0; background: transparent; color: #0e7490; cursor: pointer; font-size: 13px; line-height: 1; padding: 0; }
.hl-ai-action-files { display: flex; flex-wrap: wrap; gap: 5px; padding: 0 11px 7px; }
@media (max-width: 820px) {
  #hl-ai-attach { width: 34px; flex-basis: 34px; }
}
.hl-ai-links { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px 34px; }
.hl-ai-links a { display: inline-block; padding: 5px 10px; border-radius: 8px; background: #eff6ff; border: 1px solid #bfdbfe; color: #0369a1; font-size: 10.5px; text-decoration: none; }
.hl-ai-links a:hover { background: #dbeafe; }
@media (max-width: 820px) { .hl-ai-links { margin-left: 0; } }
.hl-ai-trace { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin: 0 0 10px 34px; font-size: 10px; color: #64748b; }
.hl-ai-trace span { margin-right: 2px; }
.hl-ai-trace i { font-style: normal; padding: 2px 7px; border-radius: 999px; background: #f1f5f9; border: 1px solid #e2e8f0; color: #475569; }
@media (max-width: 820px) { .hl-ai-trace { margin-left: 0; } }
.hl-ai-anomaly { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin: 0 0 10px 34px; font-size: 10px; }
.hl-ai-anomaly b { color: #b45309; font-weight: 600; margin-right: 2px; }
.hl-ai-anomaly span { padding: 2px 7px; border-radius: 999px; background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
@media (max-width: 820px) { .hl-ai-anomaly { margin-left: 0; } }
