:root {
  --blue: #1677ff;
  --blue-soft: #e8f3ff;
  --ink: #1f2329;
  --sub: #8a94a6;
  --line: #eef0f4;
  --bg: #f5f7fb;
  --danger: #ff4d4f;
  --green: #52c41a;
  --gold: #faad14;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: #fff;
  overflow: auto;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
#root { height: 100%; }

.login-page {
  position: relative;
  min-height: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #001529;
  padding: 24px 16px 48px;
}
.login-ellipse {
  position: absolute;
  left: 50%;
  bottom: -32rem;
  height: 64rem;
  width: auto;
  transform: translateX(-50%);
  clip-path: inset(0 0 50% 0);
  -webkit-mask-image: radial-gradient(closest-side, #fff, transparent);
  mask-image: radial-gradient(closest-side, #fff, transparent);
  z-index: 0;
  pointer-events: none;
}
.login-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}
.login-brand {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 28px;
  animation: login-in 0.7s ease-out;
}
.login-brand img {
  width: min(280px, 72vw);
  height: auto;
  object-fit: contain;
  margin-bottom: 14px;
}
.login-brand h1 {
  margin: 0;
  color: #fff;
  font-size: 32px;
  font-weight: 500;
  letter-spacing: 1px;
  text-align: center;
}
.login-card {
  position: relative;
  z-index: 2;
  width: min(440px, 100%);
  background: hsla(0, 0%, 100%, 0.08);
  border: 1px solid hsla(0, 0%, 100%, 0.1);
  border-radius: 12px;
  padding: 32px;
  box-shadow: 0 12px 48px 16px rgba(0, 0, 0, 0.08);
  animation: login-in 0.55s ease-out;
}
.login-page label {
  color: hsla(0, 0%, 100%, 0.7);
  font-size: 14px;
  font-weight: 400;
  margin: 0 0 8px;
}
.login-page label + .field { margin-bottom: 16px; }
.login-page .field {
  height: 40px;
  background: hsla(0, 0%, 100%, 0.1);
  border: 1px solid hsla(0, 0%, 100%, 0.2);
  color: #fff;
  padding-left: 16px;
}
.login-page .field::placeholder { color: hsla(0, 0%, 100%, 0.5); }
.login-page .field:focus {
  background: hsla(0, 0%, 100%, 0.2);
  border-color: #06b6d4;
  box-shadow: 0 0 0 2px rgba(6, 182, 212, 0.2);
}
.login-page .primary.wide {
  height: 48px;
  margin-top: 8px;
  background: #06b6d4;
  font-size: 16px;
  font-weight: 500;
}
.login-page .primary.wide:hover { background: rgba(6, 182, 212, 0.85); }
@keyframes login-in {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: none; }
}
label { display: block; font-size: 13px; margin: 12px 0 6px; color: #667085; }
.field, .info-input, .info-select, .search, .select, textarea.composer-input {
  width: 100%;
  border: 1px solid #e4e7ec;
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  outline: none;
}
.field:focus, textarea.composer-input:focus, .info-input:focus, .info-select:focus { border-color: #91caff; }
.primary, .ghost, .danger, .text-btn {
  border-radius: 8px;
  padding: 8px 14px;
  border: 1px solid transparent;
}
.primary { background: var(--blue); color: #fff; }
.primary:disabled { background: #b7d4ff; }
.ghost { background: #fff; border-color: #d0d5dd; }
.danger { background: #fff; color: var(--danger); border-color: #ffccc7; }
.text-btn { background: transparent; border: 0; color: #344054; padding: 6px 8px; }
.text-btn.active { color: var(--blue); }
.wide { width: 100%; margin-top: 18px; padding: 11px 14px; }

.app { min-width: 1180px; height: 100%; display: flex; background: var(--bg); }
.rail {
  width: 76px;
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 0;
  gap: 4px;
}
.logo {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  overflow: hidden;
  background: #07111f;
  margin-bottom: 8px;
}
.logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
}
.rail-item {
  width: 64px;
  border: 0;
  background: transparent;
  border-radius: 10px;
  color: #667085;
  padding: 7px 0 6px;
  display: grid;
  justify-items: center;
  gap: 2px;
  position: relative;
}
.rail-item span { font-size: 11px; }
.rail-item.active, .rail-item:hover { background: var(--blue-soft); color: var(--blue); }
.badge, .count {
  background: var(--danger);
  color: #fff;
  border-radius: 99px;
  font-size: 10px;
  min-width: 16px;
  padding: 0 4px;
  line-height: 16px;
  font-style: normal;
  text-align: center;
}
.badge {
  position: absolute;
  top: 2px;
  right: 8px;
}
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 52px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}
.topbar h2 { margin: 0; font-size: 16px; font-weight: 650; }
.me { display: flex; align-items: center; gap: 10px; }
.me-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: transparent;
  border-radius: 8px;
  padding: 4px 6px;
  text-align: left;
}
.me-btn:hover { background: #f2f4f7; }
.me-btn strong { display: block; font-size: 13px; line-height: 1.2; }
.me-btn em { display: block; font-style: normal; color: var(--sub); font-size: 12px; }
.person { display: inline-flex; align-items: center; gap: 8px; }
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; display: block; }
.profile-avatar { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.profile-avatar .avatar { width: 56px; height: 56px; font-size: 22px; }
.profile-file {
  display: inline-block;
  margin-bottom: 4px;
  padding: 4px 10px;
  font-size: 13px;
}
.status-select { border: 1px solid #e4e7ec; border-radius: 8px; padding: 6px 8px; background: #fff; }
.stage { flex: 1; min-height: 0; display: flex; }
.page { flex: 1; overflow: auto; padding: 20px 24px 40px; }
.page h3 { margin: 0 0 4px; }
.lead { color: var(--sub); margin: 0 0 16px; }

.conv-col, .info-col, .chat-col { background: #fff; min-height: 0; }
.conv-col { width: 292px; border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.chat-col { flex: 1; min-width: 420px; display: flex; flex-direction: column; background: #f7f8fa; }
.info-col { width: 332px; border-left: 1px solid var(--line); overflow: auto; }
.conv-tools { padding: 12px; display: grid; gap: 8px; border-bottom: 1px solid var(--line); }
.conv-tabs { display: flex; gap: 4px; }
.conv-tab {
  flex: 1;
  border: 0;
  background: #f5f7fb;
  border-radius: 8px;
  padding: 6px 0;
  color: #667085;
  font-size: 12px;
}
.conv-tab.active { background: var(--blue-soft); color: var(--blue); }
.conv-list { overflow: auto; flex: 1; }
.conv-item {
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid #f6f7f9;
  background: #fff;
  padding: 12px;
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 8px;
}
.conv-item.active { background: #f0f7ff; }
.avatar, .avatar.sm {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
}
.conv-item b { font-weight: 650; }
.presence { font-style: normal; font-weight: 500; font-size: 12px; margin-left: 4px; }
.presence.on { color: var(--green); }
.presence.off { color: #98a2b3; }
.conv-top, .conv-sub { display: flex; justify-content: space-between; gap: 8px; }
.muted { color: var(--sub); font-size: 12px; }
.preview { color: #667085; font-size: 12px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot-online { color: var(--green); }
.star { color: var(--gold); }

.chat-head { background: #fff; border-bottom: 1px solid var(--line); padding: 8px 12px 10px; }
.chat-tools { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.chat-actions { display: flex; align-items: center; gap: 2px; }
.sep { width: 1px; height: 14px; background: #e5e7eb; margin: 0 4px; }
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.tag, .tag-add {
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 12px;
  background: #f2f4f7;
}
.tag-add { border: 1px solid #91caff; background: #fff; color: var(--blue); }
.tag button { border: 0; background: transparent; color: #98a2b3; padding: 0 0 0 4px; }
.device-row, .source-row { display: flex; gap: 8px; align-items: flex-start; color: #667085; font-size: 13px; margin-top: 6px; }
.source-row > .muted { flex: 0 0 64px; }
.source-row a { color: var(--blue); word-break: break-all; }
.msgs { flex: 1; overflow: auto; padding: 16px 18px 8px; }
.more { text-align: center; color: #b0b7c3; font-size: 12px; margin-bottom: 8px; }
.divider { text-align: center; color: #b0b7c3; font-size: 12px; margin: 12px 0; }
.msg { display: flex; margin: 8px 0; }
.msg.mine, .msg.internal { justify-content: flex-end; }
.msg.system { justify-content: center; }
.bubble {
  max-width: min(68%, 560px);
  background: #fff;
  border: 1px solid #e6ebf2;
  border-radius: 10px;
  padding: 10px 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  text-align: left;
}
.msg.visitor .bubble { background: #e8f3ff; border-color: #d6e8ff; cursor: pointer; }
.msg.internal .bubble { background: #fff7e6; border: 1px dashed #ffd591; }
.msg.system .bubble { background: transparent; border: 0; color: var(--sub); font-size: 12px; padding: 0; }
.msg-media { display: block; max-width: 240px; max-height: 180px; border-radius: 8px; cursor: zoom-in; }
.viewer {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: #000;
  color: #fff;
  display: flex;
  flex-direction: column;
}
.viewer-bar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; }
.viewer-bar span { margin-right: auto; }
.viewer-bar button {
  width: 36px;
  height: 36px;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 22px;
}
.viewer-stage { flex: 1; display: grid; place-items: center; overflow: hidden; }
.viewer-stage img { max-width: 92vw; max-height: calc(100vh - 64px); object-fit: contain; }
video.msg-media { max-width: 280px; background: #111; }
.source-row b { font-weight: 500; color: #344054; }
.msg-meta { font-size: 12px; color: var(--sub); margin-bottom: 4px; display: flex; gap: 6px; align-items: center; }
.ticks { width: 16px; height: 12px; flex: none; }
.ticks path { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ticks.sent { color: #98a2b3; }
.ticks.read { color: #1677ff; width: 20px; }
.msg.mine .msg-meta, .msg.internal .msg-meta { justify-content: flex-end; }
.pill { background: #e8f3ff; color: var(--blue); border-radius: 4px; padding: 0 6px; font-size: 11px; }
.zh-line { margin-top: 8px; padding-top: 6px; border-top: 1px dashed #c5ddf8; color: #0958d9; font-size: 13px; }
.quote-block { border-left: 3px solid #91caff; padding: 2px 8px; margin-bottom: 6px; color: #667085; font-size: 12px; }
.composer-wrap { background: #fff; border-top: 1px solid var(--line); padding: 8px 12px 10px; }
.reply-tabs { display: flex; gap: 16px; }
.reply-tabs button { border: 0; background: transparent; padding: 6px 0; color: #667085; }
.reply-tabs button.active { color: var(--blue); box-shadow: inset 0 -2px 0 var(--blue); }
.paste-preview { display: flex; align-items: flex-start; gap: 8px; margin: 4px 0 8px; }
.paste-preview img { width: 96px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: #f8fafc; }
.composer-input { min-height: 74px; resize: vertical; border: 0; padding: 8px 2px; }
.composer-input:focus { border: 0; }
.hint { color: #b0b7c3; font-size: 12px; display: flex; justify-content: space-between; }
.picker, .quote-bar {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  margin-bottom: 8px;
}
.picker button, .quote-bar { display: block; width: 100%; text-align: left; }
.quote-bar { display: flex; justify-content: space-between; align-items: center; }
.emoji-pop { display: flex; flex-wrap: wrap; gap: 4px; }
.emoji-pop button { width: auto; font-size: 18px; border: 0; background: transparent; }

.msg-menu {
  position: fixed;
  z-index: 30;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.14);
  padding: 6px;
  min-width: 148px;
}
.msg-menu button {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  border-radius: 6px;
  padding: 8px 10px;
}
.msg-menu button:hover { background: #f5f7fb; }

.who { display: flex; gap: 10px; align-items: center; padding: 16px 16px 8px; }
.who .avatar { width: 42px; height: 42px; }
.section { padding: 8px 16px 14px; border-top: 1px solid var(--line); }
.section h4 { margin: 8px 0; font-size: 14px; display: flex; justify-content: space-between; }
.kv { display: grid; grid-template-columns: 76px 1fr auto; gap: 6px; align-items: center; margin: 6px 0; font-size: 13px; }
.kv span { color: var(--sub); }
.info-input, .info-select { border-color: transparent; background: transparent; padding: 5px 6px; }
.info-input:hover, .info-input:focus, .info-select:hover, .info-select:focus { border-color: #d6e4ff; background: #fff; }
.icon-btn { border: 0; background: transparent; color: #98a2b3; }
.empty { color: var(--sub); padding: 28px 16px; text-align: center; }

.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.card, .panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
}
.card b { display: block; font-size: 26px; margin-top: 6px; }
.toolbar { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 12px; overflow: hidden; }
.table th, .table td { border-bottom: 1px solid var(--line); text-align: left; padding: 10px 12px; font-size: 13px; vertical-align: top; }
.table th { background: #fafbfc; color: #667085; font-weight: 600; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover { background: #f8fbff; }
.linkish { color: var(--blue); background: none; border: 0; padding: 0; }
.split { display: grid; grid-template-columns: 240px 1fr; gap: 16px; }
.role-item { width: 100%; text-align: left; border: 1px solid transparent; background: #fff; border-radius: 8px; padding: 10px; margin-bottom: 6px; }
.role-item.active { border-color: #91caff; background: #f0f7ff; }
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
.checks label { display: flex; gap: 6px; align-items: center; margin: 0; color: var(--ink); }
.mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  display: grid;
  place-items: center;
  z-index: 40;
}
.dialog { width: 460px; max-width: calc(100vw - 32px); max-height: calc(100vh - 48px); overflow: auto; background: #fff; border-radius: 12px; padding: 18px; }
.dialog h3 { margin: 0 0 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.toast {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: #1f2329;
  color: #fff;
  border-radius: 8px;
  padding: 10px 14px;
  z-index: 50;
}
.channel-link { word-break: break-all; background: #f8fafc; border-radius: 8px; padding: 10px; font-size: 13px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.status-dot.online { background: var(--green); }
.status-dot.busy { background: var(--gold); }
.status-dot.offline { background: #d0d5dd; }
@media (max-width: 960px) {
  .login-brand h1 { font-size: 26px; }
  .login-card { padding: 24px 18px; }
}
@media (max-width: 860px) {
  html, body {
    position: fixed;
    left: 0;
    right: 0;
    top: var(--app-top, 0px);
    width: 100%;
    height: var(--app-h, 100dvh);
    overflow: hidden;
    overscroll-behavior: none;
  }
  body {
    padding-top: constant(safe-area-inset-top);
    padding-top: env(safe-area-inset-top);
    padding-bottom: constant(safe-area-inset-bottom);
    padding-bottom: env(safe-area-inset-bottom);
  }
  #root { height: 100%; overflow: hidden; }
  .app {
    min-width: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
  }
  .rail { width: 58px; overflow-y: auto; padding-top: 8px; }
  .logo { width: 40px; height: 40px; border-radius: 10px; margin-bottom: 4px; }
  .rail-item { width: 50px; padding: 6px 0; }
  .rail-item span { font-size: 10px; }
  .topbar { height: auto; min-height: 48px; flex-wrap: nowrap; padding: 8px 10px; gap: 6px; }
  .topbar h2 { font-size: 15px; white-space: nowrap; flex: 0 0 auto; }
  .me { flex-wrap: nowrap; gap: 6px; min-width: 0; justify-content: flex-end; }
  .me-btn { max-width: none; padding-right: 4px; }
  .me-btn > span:last-child { display: none; }
  .stage, .main, .conv-col, .chat-col, .info-col { min-width: 0; }
  .chat-col { min-width: 0; }
  .is-phone .conv-col,
  .is-phone .chat-col,
  .is-phone .info-col { display: none; width: auto; flex: 1; }
  .is-phone.phone-list .conv-col { display: flex; }
  .is-phone.phone-chat .chat-col { display: flex; }
  .is-phone.phone-info .info-col { display: block; overflow: auto; }
  .chat-tools, .chat-actions { flex-wrap: wrap; align-items: center; }
  .is-phone .device-row,
  .is-phone .source-row { display: none; }
  .text-btn, .ghost, .reply-tabs button { white-space: nowrap; }
  .reply-tabs { flex-wrap: wrap; gap: 4px 12px; }
  .reply-tabs button { flex: 0 0 auto; }
  .hint { flex-wrap: wrap; align-items: center; gap: 8px; }
  .hint .primary { margin-left: auto; }
  .composer-wrap { padding-bottom: 10px; }
  .push-banner {
    width: 100%;
    border: 0;
    background: #e8f3ff;
    color: #1677ff;
    border-radius: 8px;
    padding: 10px 12px;
    text-align: left;
    line-height: 1.45;
    font-size: 13px;
  }
  .page { padding: 12px; }
}
@media (max-width: 860px) and (display-mode: standalone) {
  body {
    padding-top: max(constant(safe-area-inset-top), 47px);
    padding-top: max(env(safe-area-inset-top), 47px);
  }
}
