/* 客服站 · 白色清爽主题 */
:root {
  --kf-bg: #f5f7fa;
  --kf-surface: #ffffff;
  --kf-surface-2: #fafafa;
  --kf-gold: #b8860b;
  --kf-gold-2: #d4b87a;
  --kf-text: #1f2937;
  --kf-text-2: #374151;
  --kf-muted: #6b7280;
  --kf-line: #e5e7eb;
  --kf-line-gold: rgba(212, 184, 122, 0.45);
  --kf-primary: #2563eb;
  --kf-danger: #dc2626;
}

/* —— 通用页面（登录 / 设置 / 统计）—— */
.kf-page {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  background: var(--kf-bg);
  color: var(--kf-text);
}
.kf-page a { color: var(--kf-gold); }
.kf-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--kf-surface);
  border-bottom: 1px solid var(--kf-line);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.03);
}
.kf-top h1 { margin: 0; font-size: 17px; color: var(--kf-text); font-weight: 700; }
.kf-wrap { max-width: 920px; margin: 0 auto; padding: 18px; }
.kf-wrap-wide { max-width: 980px; margin: 0 auto; padding: 18px; }
.kf-card {
  background: var(--kf-surface);
  border: 1px solid var(--kf-line);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.kf-card h2 { margin: 0 0 12px; font-size: 15px; color: var(--kf-gold); font-weight: 700; }
.kf-label { display: block; font-size: 13px; color: var(--kf-muted); margin: 10px 0 6px; }
.kf-input,
.kf-page input:not([type="checkbox"]),
.kf-page textarea,
.kf-page select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: var(--kf-surface);
  color: var(--kf-text);
  font-size: 14px;
}
.kf-input:focus,
.kf-page input:focus,
.kf-page textarea:focus {
  outline: 0;
  border-color: var(--kf-gold-2);
  box-shadow: 0 0 0 3px rgba(212, 184, 122, 0.2);
}
.kf-page textarea { min-height: 88px; resize: vertical; line-height: 1.5; }
.kf-hint { font-size: 12px; color: var(--kf-muted); margin-top: 4px; line-height: 1.5; }
.kf-btn {
  display: inline-block;
  padding: 10px 16px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, #d4b87a, #a88848);
  color: #1a1408;
  font-weight: 700;
  cursor: pointer;
  font-size: 14px;
}
.kf-btn.danger { background: var(--kf-danger); color: #fff; }
.kf-msg { padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; font-size: 13px; }
.kf-msg.ok { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.kf-msg.err { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.kf-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* —— 登录页 —— */
.kf-login-shell {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  padding-top: max(24px, env(safe-area-inset-top));
  padding-bottom: max(24px, env(safe-area-inset-bottom));
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  background:
    radial-gradient(circle at 20% 10%, rgba(37, 99, 235, 0.06) 0%, transparent 42%),
    radial-gradient(circle at 80% 90%, rgba(184, 134, 11, 0.07) 0%, transparent 38%),
    linear-gradient(165deg, #f8fafc 0%, #f1f5f9 48%, #eef2ff 100%);
  color: var(--kf-text);
}
.kf-login-layout {
  width: 100%;
  max-width: 420px;
}
.kf-login-card {
  width: 100%;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 20px;
  padding: 36px 32px 28px;
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.04),
    0 16px 48px rgba(15, 23, 42, 0.08);
  backdrop-filter: blur(12px);
}
.kf-login-head {
  text-align: center;
  margin-bottom: 28px;
}
.kf-login-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.kf-login-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.kf-login-field label {
  font-size: 13px;
  font-weight: 600;
  color: #475569;
  letter-spacing: 0.02em;
}
.kf-login-input {
  width: 100%;
  height: 48px;
  margin: 0;
  padding: 0 14px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #f8fafc;
  color: var(--kf-text);
  font-size: 15px;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  -webkit-appearance: none;
  appearance: none;
}
.kf-login-input::placeholder {
  color: #94a3b8;
}
.kf-login-input:hover {
  border-color: #cbd5e1;
  background: #fff;
}
.kf-login-input:focus {
  outline: 0;
  border-color: #93c5fd;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12);
}
.kf-login-submit {
  width: 100%;
  height: 48px;
  margin-top: 4px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.28);
  transition: transform 0.12s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}
.kf-login-submit:hover {
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.34);
}
.kf-login-submit:active {
  transform: scale(0.985);
  opacity: 0.95;
}
.kf-login-card .kf-msg {
  margin-bottom: 18px;
  border-radius: 10px;
  font-size: 13px;
}
.kf-login-foot {
  margin: 22px 0 0;
  padding: 12px 14px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid #eef2f7;
  font-size: 12px;
  line-height: 1.6;
  color: #64748b;
  text-align: center;
}
.kf-login-foot strong {
  color: #334155;
  font-weight: 700;
}
.kf-login-logo-row { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.kf-login-logo-row img { height: 40px; width: auto; max-width: 120px; object-fit: contain; }

/* —— 全站统一 Logo —— */
.kf-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.kf-brand-mark {
  display: block;
  flex-shrink: 0;
  filter: drop-shadow(0 1px 2px rgba(154, 128, 72, 0.18));
}
.kf-brand-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  line-height: 1.15;
}
.kf-brand-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--kf-gold);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kf-brand-sub {
  font-size: 11px;
  font-weight: 500;
  color: var(--kf-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kf-brand--compact .kf-brand-title { font-size: 15px; }
.kf-brand--compact .kf-brand-mark { width: 34px; height: 34px; }
.kf-brand--visitor .kf-brand-title { font-size: 17px; }
.kf-brand--visitor .kf-brand-mark { width: 44px; height: 44px; }
.kf-brand--login {
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 16px;
  margin-bottom: 0;
}
.kf-brand--login .kf-brand-copy { align-items: center; gap: 6px; }
.kf-brand--login .kf-brand-title {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #0f172a;
}
.kf-brand--login .kf-brand-sub {
  font-size: 14px;
  font-weight: 500;
  color: #64748b;
}
.kf-brand--login .kf-brand-mark {
  width: 64px;
  height: 64px;
  filter: drop-shadow(0 8px 20px rgba(154, 128, 72, 0.22));
}
.kf-brand--top .kf-brand-title { font-size: 17px; color: var(--kf-text); }
.kf-brand--top .kf-brand-mark { width: 30px; height: 30px; }
.kf-top-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.kf-top-page {
  font-size: 13px;
  color: var(--kf-muted);
  padding-left: 12px;
  border-left: 1px solid var(--kf-line);
  white-space: nowrap;
}
.head-brand-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex-shrink: 0;
}
.left-brand {
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--kf-line);
  background: linear-gradient(180deg, #fffbeb 0%, #fff 100%);
  flex-shrink: 0;
}
.kf-brand--sidebar .kf-brand-title { font-size: 15px; }
.kf-brand--sidebar .kf-brand-sub { font-size: 11px; }

@media (max-width: 720px) {
  .kf-top-page { display: none; }
  .kf-brand--compact .kf-brand-copy { display: none; }
}

@media (max-width: 720px) { .kf-grid2 { grid-template-columns: 1fr; } }

/* —— 后台通用 · 手机端 —— */
@media (max-width: 768px) {
  .kf-page {
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .kf-top {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px 14px;
    padding-top: max(12px, env(safe-area-inset-top));
  }
  .kf-top-left {
    min-width: 0;
  }
  .kf-top-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
    font-size: 13px;
    line-height: 1.5;
  }
  .kf-top-nav a {
    white-space: nowrap;
  }
  .kf-wrap,
  .kf-wrap-wide {
    padding: 12px;
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }
  .kf-card {
    padding: 14px;
    border-radius: 10px;
  }
  .kf-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .kf-kpi .n { font-size: 22px; }
  .kf-bars {
    height: 120px;
    gap: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
  }
  .kf-bar-col { min-width: 36px; }
  .kf-table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -4px;
    padding: 0 4px 2px;
  }
  .kf-table-scroll .kf-table {
    min-width: 520px;
  }
  .kf-login-shell {
    padding: 16px 12px;
  }
  .kf-login-card {
    padding: 28px 22px 22px;
    border-radius: 16px;
  }
  .kf-brand--login .kf-brand-title { font-size: 21px; }
  .kf-brand--login .kf-brand-mark { width: 56px; height: 56px; }
  .kefu-modal {
    padding: 16px;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    align-items: flex-end;
  }
  .kefu-modal-panel {
    width: 100%;
    border-radius: 14px 14px 0 0;
    max-height: min(88vh, 100dvh);
    overflow-y: auto;
  }
}

/* —— 工作台 · 手机端 —— */
@media (max-width: 768px) {
  .workbench-app:not(.admin-console) .head {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    align-items: center;
    gap: 6px 8px;
    padding: 8px 10px;
    padding-left: max(10px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
  }
  .workbench-app:not(.admin-console) .sess-toggle {
    grid-column: 1;
    grid-row: 1;
    margin: 0;
  }
  .workbench-app:not(.admin-console) .head-brand-wrap {
    display: none;
  }
  .workbench-app:not(.admin-console) #title {
    grid-column: 2;
    grid-row: 1;
    margin: 0;
    font-size: 15px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .workbench-app:not(.admin-console) .head-user {
    grid-column: 3;
    grid-row: 1;
    margin-left: 0;
    font-size: 11px;
    max-width: 88px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .workbench-app:not(.admin-console) .head-user a {
    display: none;
  }
  .workbench-app:not(.admin-console) .head-actions {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    margin: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    padding-bottom: 2px;
    scrollbar-width: none;
  }
  .workbench-app:not(.admin-console) .head-actions::-webkit-scrollbar {
    display: none;
  }
  .workbench-app:not(.admin-console) .head-act {
    flex-shrink: 0;
    padding: 6px 10px;
    font-size: 12px;
  }
  .workbench-app .session-ops-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 10px;
  }
  .workbench-app .ops-status-btns,
  .workbench-app .ops-note-wrap {
    width: 100%;
    min-width: 0;
  }
  .workbench-app .ops-note-wrap {
    flex-wrap: wrap;
  }
  .workbench-app .ops-meta {
    margin-left: 0;
    width: 100%;
    line-height: 1.45;
  }
  .workbench-app .player-info-bar {
    white-space: normal;
    overflow-x: visible;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
  }
  .workbench-app .pi-actions {
    margin-left: 0;
    width: 100%;
  }
  .workbench-app .quick-bar {
    padding-top: 8px;
    padding-bottom: 8px;
  }
  .workbench-app .quick-label {
    display: none;
  }
  .workbench-app .quick-scroll {
    width: 100%;
  }
  .workbench-app .kf-composer-bar .kf-input-wrap input {
    font-size: 16px;
  }
  .workbench-app .m img.bubble-img,
  .workbench-app .m.agent .bubble-img {
    max-width: min(72vw, 240px);
  }
  .workbench-app .chat-empty-open {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 14px;
    padding: 10px 18px;
    border: 0;
    border-radius: 999px;
    background: linear-gradient(135deg, #d4b87a, #a88848);
    color: #1a1408;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
  }
  .workbench-app .left-foot-nav {
    display: flex;
    flex-shrink: 0;
    border-top: 1px solid var(--kf-line);
    background: #fff;
    padding: 10px 12px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    gap: 8px;
  }
  .workbench-app .left-foot-nav a {
    flex: 1;
    text-align: center;
    padding: 9px 8px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    background: #f9fafb;
    color: #374151;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
  }
  .workbench-app .left-foot-nav a:active {
    background: #eff6ff;
    border-color: #93c5fd;
    color: #1d4ed8;
  }
}

@media (min-width: 769px) {
  .workbench-app .chat-empty-open,
  .workbench-app .left-foot-nav {
    display: none !important;
  }
}

.workbench-app .chat-empty-open[hidden] {
  display: none !important;
}

.kf-btn.secondary {
  background: transparent;
  border: 1px solid var(--kf-line-gold);
  color: var(--kf-gold);
}
.kf-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.kf-table th,
.kf-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--kf-line);
  text-align: left;
  vertical-align: top;
}
.kf-table th { color: var(--kf-gold); font-weight: 600; }
.kf-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.kf-kpi .n { font-size: 28px; font-weight: 700; color: var(--kf-text); line-height: 1.1; }
.kf-kpi .l { font-size: 12px; color: var(--kf-muted); margin-top: 6px; }
.kf-bars { display: flex; align-items: flex-end; gap: 8px; height: 140px; padding-top: 8px; }
.kf-bar-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  height: 100%;
  justify-content: flex-end;
}
.kf-bar {
  width: 100%;
  max-width: 36px;
  background: linear-gradient(180deg, #d4b87a, #8b7340);
  border-radius: 6px 6px 0 0;
  min-height: 4px;
}
.kf-bar-label { font-size: 11px; color: var(--kf-muted); }
.kf-bar-val { font-size: 11px; color: var(--kf-gold); font-weight: 600; }
.kf-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  font-size: 12px;
}

/* —— Toast / Lightbox —— */
.kefu-toast-layer {
  position: fixed;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 9999;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.kefu-toast {
  background: rgba(255, 255, 255, 0.98);
  color: var(--kf-text);
  border: 1px solid var(--kf-line);
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  animation: kefuToastIn 0.22s ease;
}
.kefu-toast.hide { opacity: 0; transform: translateY(6px); transition: 0.28s ease; }
@keyframes kefuToastIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.kefu-lightbox {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.88);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.kefu-lightbox.open { display: flex; }
.kefu-lightbox img {
  max-width: min(96vw, 900px);
  max-height: 90vh;
  border-radius: 8px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}
.kefu-lightbox-close {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 24px;
  cursor: pointer;
}
img.bubble-img { cursor: zoom-in; }

/* —— 底部输入栏 —— */
.kf-composer-bar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 10px;
  padding-left: max(10px, env(safe-area-inset-left));
  padding-right: max(10px, env(safe-area-inset-right));
  background: var(--kf-surface);
  border-top: 1px solid var(--kf-line);
}
.kf-composer-bar .kf-input-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 2px;
  min-height: 42px;
  padding: 0 6px 0 4px;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 21px;
}
.kf-composer-bar .kf-input-wrap input {
  flex: 1;
  min-width: 0;
  height: 38px;
  margin: 0;
  padding: 0 8px;
  border: 0;
  background: transparent;
  outline: none;
  font-size: 15px;
  color: var(--kf-text);
  font-family: inherit;
}
.kf-composer-bar .kf-input-wrap input::placeholder { color: #9ca3af; }
.kf-composer-bar .kf-input-wrap input:disabled {
  color: #9ca3af;
  cursor: not-allowed;
}
.kf-tool-btn {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
  color: #64748b;
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}
.kf-tool-btn .kf-icon {
  width: 20px;
  height: 20px;
}
.kf-tool-btn:hover { background: #e5e7eb; color: #374151; }
.kf-tool-btn:active { transform: scale(0.94); }
.kf-tool-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}
.kf-tool-btn--send {
  width: 42px;
  height: 42px;
  background: linear-gradient(145deg, #e8cf7a, #9a8048);
  color: #fff;
  box-shadow: 0 2px 10px rgba(154, 128, 72, 0.28);
}
.kf-tool-btn--send .kf-icon {
  width: 21px;
  height: 21px;
  color: #fff;
}
.kf-tool-btn--send:hover {
  background: linear-gradient(145deg, #f0d98a, #a88848);
  color: #fff;
}
.kf-tool-btn--gold { color: #b8860b; }
.kf-tool-btn--gold:hover { background: #fffbeb; color: #92400e; }

/* —— 工具栏 / 通用图标 —— */
.kf-icon {
  display: block;
  flex-shrink: 0;
  color: #6b7280;
}
.icon-btn .kf-icon,
.icon-btn .kf-icon-btn-svg {
  width: 22px;
  height: 22px;
}
.send-go .kf-icon,
.send-go .kf-icon-btn-svg {
  width: 24px;
  height: 24px;
  color: #2563eb;
}
.icon-btn:hover .kf-icon,
.icon-btn:focus-visible .kf-icon {
  color: #374151;
}
.send-go:hover .kf-icon,
.send-go:focus-visible .kf-icon {
  color: #1d4ed8;
}
.eval-close .kf-icon {
  width: 20px;
  height: 20px;
  color: #9ca3af;
}
.agent-avatar img,
.agent-avatar-sm {
  border-radius: 8px;
  object-fit: cover;
  background: #fffbeb;
  border: 1px solid #fde68a;
}
.agent-avatar img {
  width: 38px;
  height: 38px;
}
.agent-avatar-sm {
  width: 32px;
  height: 32px;
}
.inline-emo {
  width: 28px;
  height: 28px;
  vertical-align: middle;
  display: inline-block;
  margin: 0 2px;
  border-radius: 6px;
}
.emoji-panel button img {
  width: 28px;
  height: 28px;
  border-radius: 6px;
}

/* —— 工作台侧栏 —— */
.left {
  background: var(--kf-surface) !important;
  border-right: 1px solid var(--kf-line) !important;
}
.left h2 {
  color: var(--kf-text) !important;
  border-bottom-color: var(--kf-line) !important;
  background: var(--kf-surface) !important;
}
.stats-bar {
  background: linear-gradient(180deg, #fffbeb, #fff) !important;
  border-bottom-color: var(--kf-line) !important;
}
.stat-chip {
  background: var(--kf-surface) !important;
  border-color: #fde68a !important;
}
.stat-chip .n { color: #b45309 !important; }
.stat-chip .l { color: var(--kf-muted) !important; }
.sess-search { border-bottom-color: var(--kf-line) !important; }
.sess-search input {
  background: var(--kf-surface) !important;
  border-color: #d1d5db !important;
  color: var(--kf-text) !important;
}
.sess-search input::placeholder { color: #9ca3af !important; }
.sess-tabs { border-bottom-color: var(--kf-line) !important; }
.sess-tabs .tab {
  background: var(--kf-surface) !important;
  border-color: #d1d5db !important;
  color: var(--kf-text-2) !important;
}
.sess-tabs .tab.active {
  background: #eff6ff !important;
  border-color: #93c5fd !important;
  color: #1d4ed8 !important;
}
.sess-toolbar { border-bottom-color: var(--kf-line) !important; background: var(--kf-surface-2) !important; }
.sessions-empty { color: var(--kf-muted) !important; }
.item { border-bottom-color: #f1f5f9 !important; }
.item .name { color: var(--kf-text) !important; }
.item .msg { color: var(--kf-muted) !important; }
.item .time { color: #9ca3af !important; }
.item.active { background: #eff6ff !important; }
.item.item-unread .name { font-weight: 700; }
.unread-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f97316;
  flex-shrink: 0;
  margin-top: 5px;
}

/* —— 工作台顶栏 —— */
.workbench-app:not(.admin-console) .head {
  background: var(--kf-surface) !important;
  border-bottom: 1px solid var(--kf-line-gold) !important;
  color: var(--kf-text) !important;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.03);
}
.head-brand-text { color: var(--kf-gold) !important; }
.workbench-app:not(.admin-console) .head-user { color: var(--kf-text-2) !important; }
.workbench-app:not(.admin-console) .head-user a { color: var(--kf-gold) !important; text-decoration: none; }
.workbench-app:not(.admin-console) .head-user a:hover { text-decoration: underline; }
.workbench-app:not(.admin-console) .sess-toggle {
  background: #f3f4f6 !important;
  color: var(--kf-text) !important;
}
.workbench-app:not(.admin-console) #title { color: var(--kf-text) !important; }
.head-act-warn {
  background: #f3f4f6 !important;
  color: var(--kf-text-2) !important;
  border-color: #d1d5db !important;
}
.head-act-danger {
  background: #fef2f2 !important;
  color: #b91c1c !important;
  border-color: #fecaca !important;
}
.head-act-copy {
  background: #fffbeb !important;
  color: #92400e !important;
  border-color: #fde68a !important;
}
.head-act-enable {
  background: #eff6ff !important;
  color: #1d4ed8 !important;
  border-color: #bfdbfe !important;
}

/* —— 玩家资料 / 会话操作 —— */
.player-info-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  background: var(--kf-surface) !important;
  border-bottom: 1px solid var(--kf-line) !important;
  color: var(--kf-text) !important;
  padding: 10px 12px;
  white-space: normal;
}
.player-info-bar[hidden] { display: none !important; }
.pi-card {
  background: var(--kf-surface-2) !important;
  border: 1px solid var(--kf-line) !important;
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 12px;
  line-height: 1.35;
}
.pi-card .k { color: var(--kf-muted); margin-right: 4px; }
.pi-card.balance .v { color: #b45309; font-weight: 700; }
.pi-actions { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.pi-btn {
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid #fde68a;
  background: #fffbeb;
  color: #92400e;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}
.pi-btn:active { opacity: 0.85; }

.session-ops-bar {
  background: var(--kf-surface-2) !important;
  border-bottom-color: var(--kf-line) !important;
}
.ops-label { color: var(--kf-muted) !important; }
.ops-btn {
  background: var(--kf-surface) !important;
  border-color: #d1d5db !important;
  color: var(--kf-text-2) !important;
}
.ops-btn.active {
  border-color: #2563eb !important;
  background: #eff6ff !important;
  color: #1d4ed8 !important;
}
.ops-note-wrap input {
  background: var(--kf-surface) !important;
  border-color: #d1d5db !important;
  color: var(--kf-text) !important;
}
.ops-meta { color: var(--kf-muted) !important; }

/* —— 聊天区 —— */
.chat,
.chat-stream,
.chat-overlay {
  background: var(--kf-bg) !important;
}
.composer,
.quick-bar,
.send.kf-composer-bar {
  background: var(--kf-surface) !important;
  border-color: var(--kf-line) !important;
}
.quick-label { color: var(--kf-muted) !important; }
.quick-chip {
  background: var(--kf-surface) !important;
  border-color: #d1d5db !important;
  color: var(--kf-text-2) !important;
}
.send input {
  background: var(--kf-surface) !important;
  border-color: #d1d5db !important;
  color: var(--kf-text) !important;
}
.kf-composer-bar .kf-input-wrap input {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}
.emoji-panel { background: var(--kf-surface) !important; border-color: var(--kf-line) !important; }
.m.user { background: var(--kf-surface) !important; border: 1px solid var(--kf-line) !important; color: var(--kf-text) !important; }
.m.system { background: #f3f4f6 !important; color: #374151 !important; border-color: #e5e7eb !important; }

.msg-time {
  font-size: 10px;
  color: #9ca3af;
  margin-top: 4px;
  text-align: right;
}

/* 工作台气泡布局（勿与访客端混用） */
.workbench-app .msg-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin: 10px 0;
  width: 100%;
}
.workbench-app .msg-row-user {
  flex-direction: row;
  justify-content: flex-start;
  align-items: flex-end;
}
.workbench-app .msg-row-user .m.user {
  margin: 0;
  max-width: min(80%, 100%);
}
.workbench-app .msg-row-user .msg-time {
  text-align: left;
  padding-left: 2px;
  flex-shrink: 0;
}
.workbench-app .msg-row-agent {
  flex-direction: row;
  justify-content: flex-end;
  align-items: flex-end;
}
.workbench-app .msg-row-agent .agent-msg-col {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  max-width: min(78%, 100%);
}
.workbench-app .msg-row-agent .msg-time {
  text-align: right;
}

/* —— 访客端 —— */
.visitor-app { background: var(--kf-surface) !important; }
.visitor-head {
  background: var(--kf-surface) !important;
  border-bottom: 1px solid var(--kf-line-gold) !important;
  color: var(--kf-text) !important;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.03);
}
.visitor-head .head-brand-title { color: var(--kf-gold) !important; }
.visitor-head .head-brand-sub { color: var(--kf-muted) !important; }
.visitor-chat {
  background: var(--kf-bg) !important;
}
.visitor-composer {
  background: var(--kf-surface) !important;
  border-top: 1px solid var(--kf-line) !important;
}
.visitor-closed-banner {
  display: none;
  padding: 10px 12px;
  background: #fef2f2;
  color: #b91c1c;
  border-bottom: 1px solid #fecaca;
  text-align: center;
  font-size: 13px;
  flex-shrink: 0;
}
.visitor-closed-banner.show { display: block; }
.head-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.25);
  flex-shrink: 0;
}

/* —— 确认弹窗 —— */
.kefu-modal {
  position: fixed;
  inset: 0;
  z-index: 12000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.kefu-modal.open { display: flex; }
.kefu-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
}
.kefu-modal-panel {
  position: relative;
  width: min(420px, 100%);
  background: var(--kf-surface);
  border: 1px solid var(--kf-line);
  border-radius: 16px;
  padding: 22px 22px 18px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.18);
  animation: kefuModalIn 0.22s ease;
}
.kefu-modal-panel--danger { border-color: #fecaca; }
@keyframes kefuModalIn {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.kefu-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: #f3f4f6;
  color: #6b7280;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.kefu-modal-close:hover { background: #e5e7eb; color: #374151; }
.kefu-modal-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 22px;
  font-weight: 700;
  margin: 0 auto 14px;
}
.kefu-modal-icon--warn {
  background: #fff7ed;
  color: #ea580c;
  border: 1px solid #fed7aa;
}
.kefu-modal-icon--delete {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
  font-size: 20px;
}
.kefu-modal-icon--info {
  background: #eff6ff;
  color: #2563eb;
  border: 1px solid #bfdbfe;
  font-size: 18px;
}
.kefu-modal-title {
  margin: 0 0 10px;
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  color: var(--kf-text);
}
.kefu-modal-msg {
  margin: 0;
  text-align: center;
  font-size: 14px;
  line-height: 1.55;
  color: var(--kf-text-2);
}
.kefu-modal-detail {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  font-size: 13px;
  line-height: 1.6;
  color: #4b5563;
}
.kefu-modal-detail ul {
  margin: 0;
  padding-left: 18px;
}
.kefu-modal-detail li + li { margin-top: 4px; }
.kefu-modal-input-wrap { margin-top: 14px; }
.kefu-modal-input-label {
  display: block;
  font-size: 12px;
  color: var(--kf-muted);
  margin-bottom: 6px;
}
.kefu-modal-input-wrap input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
}
.kefu-modal-input-wrap input:focus {
  outline: 0;
  border-color: #f87171;
  box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.2);
}
.kefu-modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}
.kefu-modal-actions .kf-btn {
  flex: 1;
  text-align: center;
  padding: 11px 14px;
}
.kefu-modal-ok:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.sess-danger-btn {
  margin-left: auto;
  padding: 5px 10px;
  border: 1px solid #fecaca;
  border-radius: 6px;
  background: #fff;
  color: #b91c1c;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}
.sess-danger-btn:active { opacity: 0.88; }
.sess-danger-btn--soft {
  border-color: #fde68a;
  color: #92400e;
  background: #fffbeb;
}

/* —— 总管理员 · 管理控制台 —— */
.admin-console {
  background: #eef2f7;
  color: #0f172a;
}
.admin-console .wrap {
  grid-template-columns: 300px minmax(0, 1fr);
}
.admin-console .left {
  border-right-color: #dbe3ef;
  background: #f8fafc;
}
.admin-console .left-brand {
  background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
  border-bottom-color: rgba(255, 255, 255, 0.08);
  padding: 16px 14px;
}
.admin-console .left-brand .kf-brand-title {
  color: #f8fafc;
}
.admin-console .left-brand .kf-brand-sub {
  color: #94a3b8;
}
.admin-console .left-brand .kf-brand-mark {
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.25));
}
.admin-console .left h2 {
  background: #f1f5f9;
  color: #334155;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: none;
  padding: 12px 14px;
  border-bottom-color: #e2e8f0;
}
.admin-console .stats-bar {
  background: linear-gradient(180deg, #f8fafc, #f1f5f9);
  border-bottom-color: #e2e8f0;
}
.admin-console .stat-chip {
  border-color: #dbeafe;
  background: #fff;
}
.admin-console .stat-chip .n {
  color: #1d4ed8;
}
.admin-console .stat-chip .l {
  color: #64748b;
}
.admin-console .right {
  background: #eef2f7;
}
.admin-console .admin-shell-head {
  flex-shrink: 0;
  box-shadow: 0 4px 18px rgba(15, 23, 42, 0.12);
}
.admin-console .admin-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  min-height: 54px;
  background: linear-gradient(90deg, #0f172a 0%, #1e293b 100%) !important;
  border-bottom: 0 !important;
  color: #f8fafc !important;
  box-shadow: none !important;
}
.admin-console .admin-topbar #title,
.admin-console .admin-topbar-brand strong {
  color: #f8fafc !important;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.admin-console .admin-topbar-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.18);
  border: 1px solid rgba(147, 197, 253, 0.35);
  color: #bfdbfe;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.admin-console .admin-topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}
.admin-console .admin-topbar-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.admin-console .admin-topbar-nav a {
  padding: 7px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #e2e8f0 !important;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
}
.admin-console .admin-topbar-nav a:hover,
.admin-console .admin-topbar-nav a:active {
  background: rgba(255, 255, 255, 0.14);
  text-decoration: none;
}
.admin-console .admin-topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: #94a3b8 !important;
  flex-shrink: 0;
}
.admin-console .admin-topbar-account {
  color: #cbd5e1;
  font-weight: 500;
}
.admin-console .admin-topbar-user a {
  color: #93c5fd !important;
  text-decoration: none;
  font-weight: 600;
}
.admin-console .admin-sess-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1) !important;
  color: #e2e8f0 !important;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.admin-console .admin-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
}
.admin-console .admin-toolbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}
.admin-console .admin-toolbar-tag {
  flex-shrink: 0;
  padding: 4px 10px;
  border-radius: 999px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
}
.admin-console .admin-toolbar-hint {
  font-size: 12px;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.admin-console .admin-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin: 0 !important;
}
.admin-console .admin-tool-btn {
  padding: 7px 12px !important;
  border-radius: 8px !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  line-height: 1.2 !important;
}
.admin-console .admin-monitor-banner {
  display: none !important;
}
.admin-console .admin-readonly-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  padding-bottom: max(14px, env(safe-area-inset-bottom));
  background: #fff;
  border-top: 1px solid #e2e8f0;
  flex-shrink: 0;
}
.admin-console .admin-readonly-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #f1f5f9;
  color: #475569;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.admin-console .admin-readonly-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.admin-console .admin-readonly-copy strong {
  font-size: 14px;
  color: #0f172a;
}
.admin-console .admin-readonly-copy span {
  font-size: 12px;
  line-height: 1.5;
  color: #64748b;
}
.admin-console .chat,
.admin-console .chat-stream {
  background: #f1f5f9 !important;
}
.admin-console .admin-foot-nav {
  background: #f8fafc;
  border-top-color: #e2e8f0;
}
.admin-console .admin-foot-nav .admin-nav-link {
  background: #fff;
  border-color: #dbeafe;
  color: #1d4ed8;
}
.admin-console .admin-foot-nav .admin-nav-link--muted {
  color: #64748b;
  border-color: #e2e8f0;
  background: #fff;
}

@media (max-width: 768px) {
  .admin-console .wrap {
    grid-template-columns: 1fr;
  }
  .admin-console .left {
    width: min(92vw, 340px);
  }
  .admin-console .right {
    display: flex;
    flex-direction: column;
    min-height: 0;
  }
  .admin-console .admin-shell-head {
    flex-shrink: 0;
  }
  .admin-console .admin-sess-toggle {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    min-height: 34px;
    padding: 0 8px;
    margin: 0;
    grid-column: 1;
  }
  .admin-console .admin-topbar {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    padding-top: max(8px, env(safe-area-inset-top));
    padding-left: max(10px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
    min-height: 0;
    flex-wrap: nowrap;
  }
  .admin-console .admin-topbar-badge {
    display: none;
  }
  .admin-console .admin-topbar-brand {
    grid-column: 2;
    gap: 0;
    min-width: 0;
  }
  .admin-console .admin-topbar-brand strong,
  .admin-console .admin-topbar #title {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px !important;
  }
  .admin-console .admin-topbar-nav {
    display: none;
  }
  .admin-console .admin-topbar-user {
    grid-column: 3;
    margin: 0;
    gap: 0;
  }
  .admin-console .admin-topbar-account {
    display: none;
  }
  .admin-console .admin-topbar-user a {
    padding: 6px 10px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.12);
    font-size: 12px;
  }
  .admin-console .admin-toolbar {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    padding-left: max(10px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
  }
  .admin-console .admin-toolbar-left {
    flex: 0 0 auto;
  }
  .admin-console .admin-toolbar-hint {
    display: none;
  }
  .admin-console .admin-toolbar-actions {
    flex: 1;
    justify-content: flex-end;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    scrollbar-width: none;
    padding-bottom: 0;
  }
  .admin-console .admin-toolbar-actions::-webkit-scrollbar {
    display: none;
  }
  .admin-console .admin-tool-btn {
    flex-shrink: 0;
    padding: 6px 10px !important;
    font-size: 11px !important;
  }
  .admin-console .admin-readonly-bar {
    flex-direction: row;
    gap: 10px;
    padding: 10px 12px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }
  .admin-console .admin-readonly-icon {
    width: 34px;
    height: 34px;
  }
  .admin-console .admin-readonly-copy span {
    display: none;
  }
  .admin-console .admin-readonly-copy strong {
    font-size: 13px;
  }
  .admin-console .chat {
    flex: 1;
    min-height: 0;
  }
  .admin-console .player-info-bar {
    white-space: normal;
    overflow-x: visible;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 10px;
  }
  .admin-console .admin-foot-nav {
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }
}
