/* AI 客服值守 · 托管版前端样式（手机优先） */
:root {
  --accent: #f97316;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f6f7f9;
  --card: #ffffff;
  --bot: #ffffff;
  --user: var(--accent);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans SC", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea { font: inherit; color: inherit; }

/* ---------------------------------------------------------------- chat */
body.is-chat { background: #eef1f5; }

.chat-shell {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  background: var(--bg);
  box-shadow: 0 0 0 1px rgba(15, 23, 42, .04);
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px calc(14px + env(safe-area-inset-top, 0px));
  padding-top: calc(14px + env(safe-area-inset-top, 0px));
  background: linear-gradient(135deg, #0b1220 0%, #16233d 100%);
  color: #fff;
  flex: 0 0 auto;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }

.avatar,
.msg-avatar {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .12);
  color: #ffb27a;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 17px;
  border: 1px solid rgba(255, 255, 255, .12);
}

.brand-text { min-width: 0; }
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: .2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { display: flex; align-items: center; gap: 6px; font-size: 12px; color: #c7d2e8; margin-top: 2px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #34d399; box-shadow: 0 0 0 3px rgba(52, 211, 153, .18); }

.lang-switch { display: flex; gap: 4px; background: rgba(255, 255, 255, .08); padding: 3px; border-radius: 10px; }
.lang-switch button {
  border: 0;
  background: transparent;
  color: #c7d2e8;
  padding: 5px 9px;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
}
.lang-switch button.on { background: #fff; color: #0b1220; font-weight: 600; }

.chat-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.day { align-self: center; font-size: 12px; color: var(--muted); background: #e8edf4; padding: 2px 10px; border-radius: 999px; }

.msg { display: flex; gap: 8px; align-items: flex-end; max-width: 92%; }
.msg.bot { align-self: flex-start; }
.msg.user { align-self: flex-end; flex-direction: row-reverse; }

.msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  font-size: 14px;
  background: #0b1220;
  color: #ffb27a;
  border: 0;
}

.bubble {
  background: var(--bot);
  border: 1px solid var(--line);
  padding: 10px 13px;
  border-radius: 14px 14px 14px 4px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
  white-space: pre-wrap;
  word-break: break-word;
}

.msg.user .bubble {
  background: var(--user);
  border-color: transparent;
  color: #fff;
  border-radius: 14px 14px 4px 14px;
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 2px 6px 38px; }
.chip {
  border: 1px solid var(--line);
  background: #fff;
  color: #334155;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }

.typing { display: inline-flex; gap: 4px; align-items: center; padding: 4px 2px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: #94a3b8; animation: bounce 1s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 80%, 100% { transform: translateY(0); opacity: .5; } 40% { transform: translateY(-4px); opacity: 1; } }

.handoff-tag {
  align-self: center;
  font-size: 12px;
  color: #b45309;
  background: #fff7ed;
  border: 1px dashed #fdba74;
  padding: 6px 12px;
  border-radius: 10px;
  margin: 4px 0;
}

.composer {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  background: #fff;
  border-top: 1px solid var(--line);
}

.composer input {
  flex: 1 1 auto;
  border: 1px solid var(--line);
  background: #f8fafc;
  border-radius: 12px;
  padding: 11px 13px;
  outline: none;
}
.composer input:focus { border-color: var(--accent); background: #fff; }

.composer button {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.composer button:disabled { opacity: .5; }

.foot { flex: 0 0 auto; text-align: center; font-size: 11px; color: var(--muted); padding: 0 12px 10px; background: #fff; }

/* ---------------------------------------------------------------- pages */
.wrap { max-width: 980px; margin: 0 auto; padding: 28px 18px 48px; }
.wrap.narrow { max-width: 460px; padding-top: 64px; }

h1 { font-size: 22px; margin: 0 0 6px; letter-spacing: .2px; }
h2 { font-size: 16px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.baseurl { font-size: 12.5px; color: var(--muted); background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.baseurl code { font-size: 12.5px; color: #0f172a; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .03);
}

.form { display: grid; gap: 12px; }
.form.grid2 { grid-template-columns: 1fr 1fr; }
.form label { display: grid; gap: 6px; font-size: 13px; color: #475569; }
.form input {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: #f8fafc;
  outline: none;
}
.form input:focus { border-color: var(--accent); background: #fff; }
.form .btn { justify-self: start; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  padding: 9px 16px;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
}
.btn.ghost { background: #fff; color: var(--accent); }
.btn.small-btn { padding: 6px 10px; font-size: 12px; }

.tenants { display: grid; gap: 14px; }
.tenant { display: flex; gap: 18px; justify-content: space-between; align-items: center; flex-wrap: wrap; }
.tenant-main { min-width: 260px; flex: 1 1 320px; }
.tenant-name { font-weight: 700; font-size: 16px; }
.tenant-qr { text-align: center; }
.tenant-qr img { width: 132px; height: 132px; display: block; border: 1px solid var(--line); border-radius: 8px; background: #fff; }

.linkrow { display: flex; gap: 8px; margin-top: 10px; }
.linkrow input {
  flex: 1 1 auto;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12.5px;
  color: #334155;
  background: #f8fafc;
}

/* inbox */
.event-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.event-q { font-weight: 600; margin-bottom: 4px; }
.tag { flex: 0 0 auto; font-size: 12px; color: #b45309; background: #fff7ed; border: 1px solid #fed7aa; border-radius: 999px; padding: 2px 10px; }

details { margin-top: 12px; }
summary { cursor: pointer; font-size: 13px; color: #475569; }
.transcript { margin-top: 10px; display: grid; gap: 8px; }
.t-row { display: grid; grid-template-columns: 34px 1fr; gap: 8px; font-size: 13.5px; padding: 8px 10px; border-radius: 10px; background: #f8fafc; }
.t-row span { color: var(--muted); font-size: 12px; }
.t-row.u { background: #fff7ed; }

.empty { color: var(--muted); text-align: center; padding: 28px 16px; }
.foot-note { margin-top: 18px; font-size: 12.5px; color: var(--muted); }

@media (max-width: 640px) {
  .form.grid2 { grid-template-columns: 1fr; }
  .tenant { align-items: flex-start; }
  .tenant-qr img { width: 110px; height: 110px; }
}
