:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --line: #e1e6ef;
  --text: #172033;
  --muted: #667085;
  --blue: #1f6feb;
  --green: #0f9f6e;
  --orange: #d97706;
  --red: #d92d20;
  --sidebar: #101828;
  --soft: #f8fafc;
  --shadow: 0 8px 22px rgba(23, 32, 51, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, #eef4ff 0, #f5f7fb 220px),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

html,
body {
  overflow-x: hidden;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(31, 111, 235, 0.08), rgba(15, 159, 110, 0.08)),
    #f5f7fb;
}

.login-shell {
  width: min(1040px, 100%);
  min-height: 620px;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(360px, 440px);
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(23, 32, 51, 0.14);
}

.login-brand-panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 42px;
  color: #fff;
  background:
    linear-gradient(rgba(17, 24, 39, 0.86), rgba(17, 24, 39, 0.78)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='900' height='700' viewBox='0 0 900 700'%3E%3Crect width='900' height='700' fill='%23111827'/%3E%3Cg fill='none' stroke='%233d74d7' stroke-width='2' opacity='.28'%3E%3Cpath d='M0 140h900M0 280h900M0 420h900M0 560h900M150 0v700M300 0v700M450 0v700M600 0v700M750 0v700'/%3E%3C/g%3E%3Cg fill='%230f9f6e' opacity='.2'%3E%3Ccircle cx='160' cy='160' r='86'/%3E%3Ccircle cx='720' cy='520' r='128'/%3E%3C/g%3E%3C/svg%3E");
  background-size: cover;
}

.login-brand,
.login-points {
  display: flex;
  align-items: center;
  gap: 12px;
}

.login-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #fff;
  color: #1f6feb;
  font-weight: 800;
}

.login-brand strong {
  display: block;
  font-size: 20px;
}

.login-brand p,
.login-copy p {
  margin: 6px 0 0;
  color: rgba(255, 255, 255, 0.74);
}

.login-copy h1 {
  max-width: 520px;
  margin: 0;
  font-size: 42px;
  line-height: 1.18;
  letter-spacing: 0;
}

.login-copy p {
  max-width: 460px;
  font-size: 16px;
  line-height: 1.8;
}

.login-points {
  flex-wrap: wrap;
}

.login-points span {
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.86);
  font-size: 13px;
}

.login-card {
  display: grid;
  align-content: center;
  padding: 42px;
}

.login-card-head {
  margin-bottom: 24px;
}

.eyebrow {
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
}

.login-card h2 {
  margin: 8px 0;
  font-size: 28px;
}

.login-card p {
  margin: 0;
  color: var(--muted);
}

.login-options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.checkline {
  display: flex !important;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 6px !important;
}

.checkline input {
  width: auto;
}

.login-submit {
  width: 100%;
}

.error {
  min-height: 22px;
  color: var(--red);
  font-size: 13px;
}

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

button {
  border: 0;
  cursor: pointer;
}

[hidden],
.permission-hidden {
  display: none !important;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
}

.sidebar {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--sidebar);
  color: #fff;
  padding: 20px 14px;
}

.brand {
  padding: 0 10px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand strong {
  display: block;
  font-size: 18px;
  margin-bottom: 6px;
}

.brand span {
  color: #b6c2d2;
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 6px;
  margin-top: 18px;
}

.nav button {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 6px;
  background: transparent;
  color: #d8dee9;
  text-align: left;
}

.nav button.active,
.nav button:hover {
  background: #243044;
  color: #fff;
}

.sidebar-account {
  margin-top: auto;
  padding: 14px 10px 0;
  border-top: 1px solid rgba(255, 255, 255, .12);
  display: grid;
  gap: 10px;
}

.sidebar-account strong,
.sidebar-account span {
  display: block;
}

.sidebar-account strong {
  font-size: 14px;
  color: #fff;
}

.sidebar-account span {
  margin-top: 3px;
  color: #b6c2d2;
  font-size: 12px;
}

.sidebar-account button {
  min-height: 34px;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 6px;
  background: rgba(255, 255, 255, .08);
  color: #fff;
  font-weight: 700;
}

.sidebar-account button:hover {
  background: rgba(255, 255, 255, .14);
}

.main {
  min-width: 0;
  padding: 16px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.topbar h1 {
  margin: 0;
  font-size: 22px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.version-pill {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  text-decoration: none;
}

.reminder-toggle.active {
  border-color: rgba(15, 159, 110, 0.35);
  background: #ecfdf3;
  color: var(--green);
}

.toast-stack {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 80;
  display: grid;
  gap: 10px;
  width: min(360px, calc(100vw - 36px));
  pointer-events: none;
}

.toast-item {
  padding: 12px 14px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 48px rgba(23, 32, 51, 0.16);
  pointer-events: none;
}

.toast-item strong {
  display: block;
  margin-bottom: 4px;
  color: #101828;
  font-size: 14px;
}

.toast-item span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: none;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.36);
}

.confirm-overlay.show {
  display: grid;
}

.confirm-dialog {
  width: min(380px, 100%);
  padding: 16px;
  border: 1px solid #d8deea;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(16, 24, 40, 0.22);
}

.confirm-dialog strong {
  display: block;
  color: #101828;
  font-size: 16px;
}

.confirm-dialog p {
  margin: 8px 0 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.reminder-center {
  position: fixed;
  top: 68px;
  right: 18px;
  z-index: 70;
  width: min(420px, calc(100vw - 36px));
  max-height: min(560px, calc(100vh - 96px));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 22px 58px rgba(23, 32, 51, 0.18);
}

.reminder-center-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.reminder-center-head span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.reminder-center-list {
  display: grid;
  gap: 8px;
  max-height: 470px;
  overflow: auto;
  padding: 10px;
}

.reminder-history-item {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  text-align: left;
}

.reminder-history-item:hover {
  border-color: #bfdbfe;
  background: #eff6ff;
}

.reminder-history-item strong,
.reminder-history-item span,
.reminder-history-item small {
  min-width: 0;
  overflow-wrap: anywhere;
}

.reminder-history-item span,
.reminder-history-item small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.reminder-center-toggle span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  min-height: 20px;
  margin-left: 4px;
  border-radius: 999px;
  background: #e0ecff;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

.cards {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
  transition: box-shadow .16s ease, transform .16s ease;
}

body:not([data-section="chat"]) .cards {
  gap: 8px;
  margin-bottom: 12px;
}

body:not([data-section="chat"]) .metric {
  border-top: 3px solid #cbd5e1;
}

body:not([data-section="chat"]) .metric:nth-child(1) {
  border-top-color: var(--blue);
}

body:not([data-section="chat"]) .metric:nth-child(2) {
  border-top-color: var(--green);
}

body:not([data-section="chat"]) .metric:nth-child(3) {
  border-top-color: var(--orange);
}

body:not([data-section="chat"]) .metric:nth-child(4),
body:not([data-section="chat"]) .metric:nth-child(5) {
  border-top-color: #9fcbc0;
}

.metric:hover,
.focus-card:hover {
  box-shadow: 0 14px 36px rgba(23, 32, 51, 0.1);
}

.metric span {
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  display: block;
  margin-top: 6px;
  font-size: 22px;
}

.section {
  display: none;
}

.section.active {
  display: block;
}

body:not([data-section="chat"]) .main {
  min-height: 100vh;
  background: #edf1f6;
}

body:not([data-section="chat"]) .topbar {
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid #d8deea;
}

body:not([data-section="chat"]) .section.active {
  display: grid;
  gap: 12px;
  padding: 8px;
  border: 1px solid #d8deea;
  border-radius: 8px;
  background: #f7f9fc;
}

body:not([data-section="chat"]) .section > .panel,
body:not([data-section="chat"]) .section > .two-col > .panel,
body:not([data-section="chat"]) .section .two-col > .panel {
  border-color: #d8deea;
}

body:not([data-section="chat"]) .section > .panel:first-child,
body:not([data-section="chat"]) .section > .two-col > .panel:first-child,
body:not([data-section="chat"]) .section .two-col > .panel:first-child {
  border-top: 3px solid #8fb4e8;
}

body:not([data-section="chat"]) .section > .two-col > .panel:nth-child(2),
body:not([data-section="chat"]) .section .two-col > .panel:nth-child(2) {
  border-top: 3px solid #9fcbc0;
}

body:not([data-section="chat"]) .section > .cards + .two-col > .panel:first-child {
  border-top-color: #d9a441;
}

body[data-section="chat"] {
  height: 100vh;
  overflow: hidden;
  background: #edf1f6;
}

body[data-section="chat"] .shell {
  height: 100vh;
  overflow: hidden;
}

body[data-section="chat"] .main {
  height: 100vh;
  overflow: hidden;
  padding: 10px 12px;
}

body[data-section="chat"] .topbar {
  min-height: 38px;
  margin-bottom: 8px;
  padding: 0 4px 0 0;
  border-bottom: 1px solid #d8deea;
}

body[data-section="chat"] .topbar h1 {
  font-size: 20px;
}

body[data-section="chat"] .topbar-actions {
  gap: 8px;
}

body[data-section="chat"] .topbar-actions .ghost,
body[data-section="chat"] .version-pill {
  min-height: 32px;
  padding: 0 10px;
  border-color: #d8deea;
  background: rgba(255, 255, 255, 0.78);
}

body[data-section="chat"] .cards {
  display: none;
}

.chat-workbench {
  display: grid;
  gap: 12px;
}

body[data-section="chat"] .chat-workbench {
  height: calc(100vh - 58px);
  grid-template-rows: auto auto auto minmax(0, 1fr);
  gap: 7px;
  overflow: hidden;
  padding: 8px;
  border: 1px solid #d8deea;
  border-radius: 8px;
  background: #f7f9fc;
}

.chat-focus-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr)) minmax(180px, 1.4fr);
  gap: 10px;
}

.focus-card {
  min-height: 58px;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: none;
}

body[data-section="chat"] .focus-card {
  min-height: 42px;
  padding: 6px 10px;
  border-top: 3px solid #cbd5e1;
}

body[data-section="chat"] .focus-card strong {
  font-size: 17px;
}

body[data-section="chat"] .focus-card:nth-child(1) {
  border-top-color: var(--orange);
}

body[data-section="chat"] .focus-card:nth-child(2) {
  border-top-color: var(--red);
}

body[data-section="chat"] .focus-card:nth-child(3) {
  border-top-color: var(--green);
}

body[data-section="chat"] .focus-card:nth-child(4) {
  border-top-color: var(--blue);
}

.focus-card span {
  color: var(--muted);
  font-size: 12px;
}

.focus-card strong {
  color: #101828;
  font-size: 20px;
}

.focus-card.wide strong {
  overflow: hidden;
  font-size: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  flex-wrap: wrap;
}

body[data-section="chat"] .chat-toolbar {
  flex-wrap: nowrap;
  gap: 10px;
  min-height: 34px;
}

.queue-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  flex: 1 1 560px;
  min-width: 0;
  padding-bottom: 1px;
}

.queue-tabs button {
  min-height: 32px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--muted);
  white-space: nowrap;
}

.queue-tabs button.active {
  border-color: rgba(31, 111, 235, 0.5);
  background: #dcecff;
  color: var(--blue);
  font-weight: 700;
  box-shadow: inset 0 -2px 0 var(--blue);
}

.queue-tabs span {
  min-width: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(31, 111, 235, 0.1);
  text-align: center;
  font-size: 12px;
}

.tag-filter,
.quick-tags {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  min-width: 0;
}

body[data-section="chat"] .tag-filter {
  padding-bottom: 2px;
}

body[data-section="chat"] .tag-filter button {
  min-height: 26px;
  padding: 0 9px;
  background: rgba(255, 255, 255, 0.72);
}

.tag-filter button,
.quick-tags button {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  white-space: nowrap;
}

.tag-filter button.active,
.quick-tags button.active {
  border-color: rgba(31, 111, 235, 0.35);
  background: #eef5ff;
  color: var(--blue);
  font-weight: 700;
}

.chat-tools {
  display: flex;
  gap: 8px;
  flex: 0 1 330px;
  min-width: 260px;
}

.chat-tools input {
  width: 100%;
  min-width: 0;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: #fff;
}

.chat-tools select {
  min-width: 108px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 8px;
  background: #fff;
  color: #344054;
}

.chat-tools .ghost {
  flex: 0 0 auto;
  min-width: 54px;
  white-space: nowrap;
}

.operator-status-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  flex-wrap: wrap;
}

.operator-status-bar select,
.inline-select {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 8px;
  background: #fff;
  color: #344054;
}

.inline-select {
  min-width: 96px;
}

.grid-chat {
  display: grid;
  grid-template-columns: minmax(280px, 330px) minmax(420px, 1fr) minmax(300px, 350px);
  gap: 14px;
  height: calc(100vh - 284px);
  min-height: 580px;
  overflow: hidden;
}

body[data-section="chat"] .grid-chat {
  grid-template-columns: minmax(260px, 300px) minmax(480px, 1fr) minmax(310px, 340px);
  gap: 8px;
  height: auto;
  min-height: 0;
}

.grid-chat > .panel {
  min-height: 0;
  overflow: hidden;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
  min-width: 0;
}

body[data-section="chat"] .conversation-panel {
  border-color: #d9a441;
}

body[data-section="chat"] .chat-panel {
  border-color: #8fb4e8;
}

body[data-section="chat"] .visitor-panel {
  border-color: #9fcbc0;
}

.panel-head {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff 0, #f8fafc 100%);
}

body[data-section="chat"] .panel-head {
  min-height: 44px;
  padding: 8px 11px;
  background: linear-gradient(180deg, #ffffff 0, #f8fafc 100%);
}

body[data-section="chat"] .panel-head.compact {
  min-height: 44px;
}

.panel-head.compact {
  min-height: 58px;
}

.panel-head h2 {
  margin: 0;
  font-size: 15px;
}

.panel-head .meta {
  display: block;
  margin-top: 3px;
  line-height: 1.35;
}

.list {
  overflow: auto;
}

.history-list-frame {
  height: min(650px, calc(100vh - 285px));
  min-height: 420px;
  border: 1px solid var(--line);
  background: #fff;
}

.history-pagination {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 8px 10px;
  border-top: 1px solid var(--line);
  background: rgba(255,255,255,.96);
}

.history-pagination label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
}

.history-pagination select {
  min-width: 76px;
  padding: 6px 8px;
}

.settings-subgroup {
  display: grid;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  background: #f8fafc;
}

.geo-diagnostic-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.session-list {
  height: calc(100% - 58px);
}

body[data-section="chat"] .session-list {
  height: calc(100% - 44px);
}

.session-item {
  width: 100%;
  display: grid;
  gap: 5px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  text-align: left;
}

.session-item.rich {
  gap: 8px;
  padding: 13px 14px;
}

.session-item.compact {
  gap: 4px;
  min-height: 78px;
  padding: 8px 10px 8px 11px;
  border-left: 4px solid transparent;
}

body[data-density="dense"] .session-item.compact {
  min-height: 62px;
  gap: 3px;
  padding: 7px 9px;
}

body[data-density="dense"] .session-item.compact .session-preview {
  display: none;
}

body[data-density="dense"] .session-item.compact .session-foot {
  font-size: 11px;
}

.session-item.active,
.session-item:hover {
  background: #e7f1ff;
}

.session-item:has(.status-chip.pending) {
  border-left-color: var(--orange);
}

.session-item.unread-new {
  background: #fffaf0;
  box-shadow: inset 0 0 0 1px rgba(217, 119, 6, 0.22);
}

.session-item.unread-new:not(.active)::after {
  content: "新消息";
  justify-self: start;
  min-height: 20px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #d97706;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}

.session-item.urgent-new {
  background: #fff5f5;
  box-shadow: inset 0 0 0 1px rgba(217, 45, 32, 0.25);
}

.session-item.vip-new:not(.active) {
  border-left-color: #7a5af8;
}

.session-item:has(.status-chip.urgent) {
  border-left-color: var(--red);
}

.session-item:has(.status-chip.lead) {
  border-left-color: var(--blue);
}

.session-title {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-weight: 700;
}

.session-title > span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-subline,
.session-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.session-preview {
  color: #344054;
  font-size: 12px;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-chip,
.status-dot,
.source-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status-chip.pending {
  background: #fff7ed;
  color: var(--orange);
}

.status-chip.urgent {
  background: #fef3f2;
  color: var(--red);
}

.status-chip.ai {
  background: #ecfdf3;
  color: var(--green);
}

.status-chip.lead {
  background: #eef5ff;
  color: var(--blue);
}

.status-chip.active,
.status-dot.online {
  background: #f1f5f9;
  color: #475467;
}

.status-chip.closed {
  background: #f2f4f7;
  color: #667085;
}

.visitor-presence {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  width: fit-content;
  min-height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.visitor-presence.online {
  background: #ecfdf3;
  color: var(--green);
}

.visitor-presence.offline {
  background: #f2f4f7;
  color: #667085;
}

.presence-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 3px rgba(18, 183, 106, .12);
}

.visitor-presence.offline .presence-dot {
  box-shadow: none;
}

.source-badge {
  background: #eef5ff;
  color: var(--blue);
}

.meta {
  color: var(--muted);
  font-size: 12px;
}

.chat-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  min-height: 0;
}

body[data-section="chat"] .chat-panel {
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  border-color: #d8deea;
}

.chat-head {
  align-items: flex-start;
  flex-wrap: wrap;
  background: #fff;
  border-top: 3px solid var(--blue);
}

.chat-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.chat-context {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.context-pill {
  max-width: 190px;
  min-height: 22px;
  display: inline-flex;
  align-items: center;
  padding: 0 7px;
  border-radius: 6px;
  background: #f3f6fa;
  color: #475467;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.messages {
  overflow: auto;
  padding: 10px 12px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(247, 249, 252, 0.72)),
    #eef3f8;
}

body[data-section="chat"] .messages {
  padding: 10px 12px;
}

.empty-state {
  margin: 10px;
  padding: 22px 14px;
  border: 1px dashed #cbd5e1;
  border-radius: 6px;
  background: #fbfcff;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.msg {
  display: flex;
  margin-bottom: 6px;
}

.msg.visitor {
  justify-content: flex-start;
}

.msg.operator,
.msg.ai {
  justify-content: flex-end;
}

.bubble {
  max-width: min(46%, 320px);
  width: fit-content;
  min-width: 0;
  position: relative;
  margin-bottom: 14px;
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 14px;
  line-height: 1.35;
  white-space: pre-wrap;
  word-break: break-word;
}

.system .bubble {
  max-width: min(52%, 360px);
}

.bubble .meta {
  position: absolute;
  top: calc(100% + 2px);
  left: 2px;
  width: max-content;
  max-width: 170px;
  margin-top: 0;
  font-size: 10px;
  line-height: 1.15;
  opacity: .72;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.operator .bubble .meta,
.ai .bubble .meta {
  right: 2px;
  left: auto;
  max-width: 150px;
}

.visitor .bubble {
  background: #fff;
  border: 1px solid var(--line);
}

.operator .bubble {
  background: #ecfdf3;
  border: 1px solid #c9eadc;
  color: var(--text);
}

.operator .bubble .meta {
  color: var(--muted);
}

.ai .bubble {
  background: #ecfdf3;
  border: 1px solid #c9eadc;
}

.system .bubble {
  background: #fff7ed;
  border: 1px solid #fed7aa;
}

.quick-replies {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 8px 10px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.quick-replies button {
  min-height: 29px;
  padding: 0 9px;
  border-radius: 6px;
  background: #f1f5f9;
  color: #344054;
  font-size: 12px;
  white-space: nowrap;
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--line);
}

body[data-section="chat"] .composer textarea {
  min-height: 54px;
}

body[data-section="chat"] .composer .primary {
  min-width: 60px;
  padding: 0 14px;
}

.visitor-panel .detail {
  height: calc(100% - 58px);
  overflow: auto;
}

body[data-section="chat"] .visitor-panel .detail {
  height: calc(100% - 44px);
  padding: 8px;
  gap: 7px;
}

.visitor-section {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.visitor-source-section {
  border-color: #cfd8e6;
  background: #fbfcff;
}

.visitor-source-section label {
  gap: 4px;
}

.visitor-source-section input,
.visitor-source-section textarea {
  background: #fff;
}

.sales-summary-section {
  border-color: #b7d3ff;
  background: #eef6ff;
}

.insight-section {
  border-color: #b7decf;
  background: #f2fbf6;
}

.location-action {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-height: 26px;
}

.map-link {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border: 1px solid #b7d3ff;
  border-radius: 6px;
  background: #eef6ff;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}

.map-link:hover {
  background: #dcecff;
}

.location-hint {
  color: var(--muted);
  font-size: 12px;
}

.sales-summary {
  white-space: pre-wrap;
  color: #1d2939;
  font-size: 12px;
  line-height: 1.55;
}

.action-config .action-row {
  margin-top: 4px;
}

body[data-section="chat"] .visitor-section {
  gap: 7px;
  padding: 9px;
}

body[data-section="chat"] .compact-config:not([open]) {
  padding: 7px 9px;
  background: #fbfcfe;
}

.visitor-section[open] {
  align-content: start;
}

.visitor-section summary {
  cursor: pointer;
  list-style-position: outside;
}

.section-title {
  color: #344054;
  font-size: 13px;
  font-weight: 800;
}

.insight-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.insight-grid div {
  min-width: 0;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
}

.insight-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.insight-grid strong {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  color: #101828;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.insight-reply {
  padding: 9px;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 12.5px;
  line-height: 1.45;
}

.profile-card {
  display: grid;
  gap: 3px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.profile-card strong {
  font-size: 15px;
}

.profile-card span {
  color: var(--muted);
  font-size: 12px;
}

.action-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.action-row button {
  padding: 0 8px;
  white-space: nowrap;
}

.settings-actions {
  grid-template-columns: repeat(2, minmax(120px, 1fr));
}

.settings-group {
  display: grid;
  gap: 10px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcff;
  border-left: 4px solid #9fcbc0;
}

.settings-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.settings-group-head strong {
  font-size: 14px;
}

.upgrade-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.deploy-access-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.ai-settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.ai-dashboard {
  grid-column: 1 / -1;
  background: #f8fbfb;
}

.ai-status-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.ai-status-card {
  min-height: 62px;
  padding: 10px;
  border: 1px solid #dbe7e5;
  border-radius: 6px;
  background: #ffffff;
  display: grid;
  align-content: center;
  gap: 5px;
}

.ai-status-card span {
  color: var(--muted);
  font-size: 12px;
}

.ai-status-card strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  color: var(--text);
}

.ai-module-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.ai-module-grid > div {
  border: 1px solid #dbe7e5;
  border-radius: 6px;
  background: #ffffff;
  padding: 10px;
  min-height: 116px;
}

.ai-module-grid h3 {
  margin: 0 0 8px;
  font-size: 13px;
}

.ai-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ai-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #eef7f5;
  border: 1px solid #cfe3de;
  color: #23594f;
  font-size: 12px;
}

.ai-rule-list {
  display: grid;
  gap: 6px;
}

.ai-rule-item {
  position: relative;
  padding-left: 12px;
  color: #334155;
  font-size: 12px;
  line-height: 1.55;
}

.ai-rule-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.72em;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #2b7a6f;
}

.support-account-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.module-permission-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.module-permission-grid label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-weight: 600;
}

.module-permission-grid input {
  width: 16px;
  height: 16px;
}

.widget-settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.widget-settings-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 420px);
  gap: 16px;
  align-items: start;
}

.widget-preview-wrap {
  display: grid;
  gap: 10px;
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
  position: sticky;
  top: 12px;
}

.widget-preview-stage {
  position: relative;
  min-height: 620px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(148, 163, 184, .12) 1px, transparent 1px),
    linear-gradient(0deg, rgba(148, 163, 184, .12) 1px, transparent 1px),
    #f8fafc;
  background-size: 24px 24px;
  overflow: hidden;
}

.widget-preview-stage.left .widget-preview-panel {
  left: var(--preview-offset-x, 22px);
  right: auto;
}

.widget-preview-stage.left .widget-preview-button {
  left: var(--preview-offset-x, 22px);
  right: auto;
}

.widget-preview-stage:not(.open) .widget-preview-panel {
  display: none;
}

.widget-preview-stage.open .widget-preview-button {
  display: none;
}

.widget-preview-panel {
  position: absolute;
  right: var(--preview-offset-x, 22px);
  bottom: calc(var(--preview-offset-y, 22px) + var(--preview-button-size, 62px) + 12px);
  width: var(--preview-panel-width, 360px);
  max-width: calc(100% - 28px);
  height: var(--preview-panel-height, 520px);
  max-height: calc(100% - var(--preview-offset-y, 22px) - var(--preview-button-size, 62px) - 34px);
  display: grid;
  grid-template-rows: 54px 1fr auto;
  overflow: hidden;
  border: 1px solid #e5e9f2;
  border-radius: var(--preview-radius, 10px);
  background: #fff;
  box-shadow: 0 18px 48px rgba(23, 32, 51, .18);
  color: #172033;
  font-family: "Microsoft YaHei", Arial, sans-serif;
}

.widget-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  color: #fff;
  background: var(--preview-primary, #176f5d);
}

.widget-preview-head strong {
  overflow: hidden;
  font-size: 15px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.widget-preview-head span {
  font-size: 20px;
}

.widget-preview-body {
  overflow: auto;
  padding: 9px;
  background: #f8fafc;
}

.widget-preview-row {
  max-width: 66%;
  margin: 0 0 5px;
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 15px;
  line-height: 1.36;
}

.widget-preview-row.ai {
  background: #fff;
  border: 1px solid #e5e9f2;
}

.widget-preview-row.visitor {
  margin-left: auto;
  color: #fff;
  background: var(--preview-primary, #176f5d);
}

.widget-preview-form {
  display: grid;
  grid-template-columns: 1fr 72px;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border-top: 1px solid #e5e9f2;
  background: #fff;
}

.widget-preview-form span {
  overflow: hidden;
  min-height: 42px;
  display: flex;
  align-items: center;
  padding: 0 9px;
  border: 1px solid #dce3ef;
  border-radius: 6px;
  color: var(--muted);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.widget-preview-form button {
  height: 42px;
  border: 0;
  border-radius: 6px;
  color: #fff;
  background: var(--preview-primary, #176f5d);
  font-size: 14px;
  font-weight: 700;
}

.widget-preview-button {
  position: absolute;
  right: var(--preview-offset-x, 22px);
  bottom: var(--preview-offset-y, 22px);
  width: var(--preview-button-size, 62px);
  height: var(--preview-button-size, 62px);
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--preview-button, #176f5d);
  box-shadow: 0 12px 30px rgba(23, 111, 93, .35);
  overflow: hidden;
}

.widget-preview-button img {
  width: 72%;
  height: 72%;
  display: block;
  margin: 14%;
  object-fit: contain;
  border-radius: 50%;
}

@media (max-width: 1100px) {
  .widget-settings-layout {
    grid-template-columns: 1fr;
  }

  .widget-preview-wrap {
    position: static;
  }
}

@media (max-width: 560px) {
  .widget-preview-stage {
    min-height: 560px;
  }

  .widget-preview-panel {
    right: 12px;
    left: auto;
    bottom: 86px;
    width: calc(100% - 24px);
    height: 70%;
    max-height: none;
  }

  .widget-preview-stage.left .widget-preview-panel {
    left: 12px;
  }

  .widget-preview-button {
    right: 12px;
    bottom: 12px;
  }

  .widget-preview-stage.left .widget-preview-button {
    left: 12px;
  }
}

.deploy-actions {
  grid-template-columns: repeat(3, minmax(120px, 1fr));
}

.upgrade-actions {
  grid-template-columns: repeat(5, minmax(112px, 1fr));
}

.deploy-access textarea {
  font-family: "Consolas", "SFMono-Regular", monospace;
  font-size: 12px;
}

.reminder-rule-grid {
  display: grid;
  grid-template-columns: minmax(70px, .8fr) minmax(70px, .7fr) minmax(96px, .9fr) minmax(72px, .7fr) minmax(72px, .7fr) minmax(82px, .7fr) minmax(170px, 1.2fr);
  gap: 8px;
  align-items: center;
}

.reminder-rule-head {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.switch-line {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #344054;
}

.switch-line input {
  width: auto;
}

.time-range {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 6px;
}

.composer textarea {
  min-height: 40px;
  max-height: 100px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px;
}

.primary {
  min-height: 36px;
  padding: 0 14px;
  border-radius: 6px;
  background: var(--blue);
  color: #fff;
}

.full-action {
  width: 100%;
}

.ghost {
  min-height: 32px;
  padding: 0 10px;
  border-radius: 6px;
  background: #f1f5f9;
  color: var(--text);
}

button:disabled,
button[data-loading="true"] {
  cursor: wait;
  opacity: 0.68;
}

button[data-loading="true"] {
  box-shadow: inset 0 0 0 1px rgba(16, 24, 40, 0.04);
}

.danger {
  background: var(--red);
  color: #fff;
}

.detail {
  padding: 11px;
}

.kv {
  display: grid;
  gap: 9px;
}

.kv label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.kv input,
.kv select,
.kv textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 9px;
  color: var(--text);
  background: #fff;
}

.kv input:focus,
.kv select:focus,
.kv textarea:focus,
.chat-tools input:focus,
.chat-tools select:focus,
.composer textarea:focus {
  outline: 0;
  border-color: #8fb4e8;
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.08);
}

.kv .checkline input {
  width: auto;
}

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.table th,
.table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 12.5px;
}

.table th {
  background: #f3f6fa;
  color: var(--muted);
  font-weight: 800;
  white-space: nowrap;
}

.table tr:last-child td {
  border-bottom: 0;
}

.table tbody tr:hover td {
  background: #f7fbff;
}

.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  gap: 10px;
}

.source-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
}

.source-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 11px;
  border-left: 4px solid #8fb4e8;
}

.source-card strong {
  display: block;
  margin-bottom: 8px;
}

.source-card p {
  margin: 4px 0;
  color: var(--muted);
  font-size: 12.5px;
}

.analytics-filter {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.analytics-filter select {
  min-width: 118px;
  height: 34px;
}

.analytics-page {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.analytics-page > *,
.analytics-main-grid > *,
.analytics-detail-panel {
  min-width: 0;
}

.analytics-overview-panel .panel-head {
  align-items: flex-start;
}

.analytics-custom-range {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.analytics-custom-range[hidden] {
  display: none;
}

.analytics-custom-range input {
  width: 138px;
  height: 34px;
}

.analytics-range-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 38px;
  padding: 0 14px 10px;
  color: var(--muted);
  font-size: 12px;
}

.analytics-range-status span:first-child {
  color: var(--text);
  font-weight: 700;
}

.analytics-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.analytics-kpi {
  min-height: 104px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.analytics-kpi-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.analytics-kpi-value {
  margin-top: 10px;
  color: var(--text);
  font-size: 25px;
  font-weight: 800;
  line-height: 1;
}

.analytics-kpi-note {
  margin-top: 9px;
  color: var(--muted);
  font-size: 11.5px;
}

.analytics-delta {
  font-size: 11px;
  font-weight: 700;
}

.analytics-delta.up {
  color: #16815f;
}

.analytics-delta.down {
  color: #d34545;
}

.analytics-delta.neutral {
  color: var(--muted);
}

.analytics-main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(300px, .8fr);
  gap: 10px;
}

.analytics-metric-select {
  width: 126px;
  height: 34px;
}

.analytics-trend-chart {
  min-height: 286px;
  padding: 16px 14px 12px;
  overflow-x: auto;
}

.analytics-chart-bars {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(34px, 1fr);
  align-items: end;
  gap: 7px;
  min-width: 100%;
  height: 250px;
  border-bottom: 1px solid var(--line);
  background-image: linear-gradient(to bottom, transparent calc(25% - 1px), #edf1f6 25%, transparent calc(25% + 1px)), linear-gradient(to bottom, transparent calc(50% - 1px), #edf1f6 50%, transparent calc(50% + 1px)), linear-gradient(to bottom, transparent calc(75% - 1px), #edf1f6 75%, transparent calc(75% + 1px));
}

.analytics-chart-item {
  display: grid;
  grid-template-rows: 20px 1fr 28px;
  align-items: end;
  height: 100%;
  text-align: center;
}

.analytics-chart-value {
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
}

.analytics-chart-track {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  height: 100%;
}

.analytics-chart-bar {
  width: min(22px, 72%);
  min-height: 2px;
  border-radius: 3px 3px 0 0;
  background: #2878d0;
  transition: height .2s ease;
}

.analytics-chart-label {
  align-self: center;
  color: var(--muted);
  font-size: 10.5px;
  white-space: nowrap;
}

.analytics-empty {
  display: grid;
  place-items: center;
  min-height: 180px;
  color: var(--muted);
  font-size: 13px;
}

.analytics-advice-list {
  display: grid;
  gap: 0;
  padding: 0 14px 10px;
}

.analytics-advice-item {
  padding: 12px 2px;
  border-bottom: 1px solid var(--line);
}

.analytics-advice-item:last-child {
  border-bottom: 0;
}

.analytics-advice-item strong {
  display: block;
  margin-bottom: 5px;
  color: var(--text);
  font-size: 13px;
}

.analytics-advice-item p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

.analytics-advice-item.warning {
  border-left: 3px solid #e6a23c;
  padding-left: 10px;
}

.analytics-advice-item.danger {
  border-left: 3px solid #d34545;
  padding-left: 10px;
}

.analytics-advice-item.success {
  border-left: 3px solid #16815f;
  padding-left: 10px;
}

.analytics-detail-head {
  align-items: center;
}

.analytics-tabs {
  flex-wrap: wrap;
}

.analytics-table-wrap {
  display: none;
  overflow: auto;
}

.analytics-table-wrap.active {
  display: block;
}

.analytics-table {
  min-width: 900px;
}

.analytics-table td:first-child {
  max-width: 320px;
  white-space: normal;
  word-break: break-word;
}

.analytics-table .analytics-primary-cell {
  color: var(--text);
  font-weight: 700;
}

.analytics-cell-sub {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
}

.analytics-footnote {
  padding: 2px 4px 10px;
  color: var(--muted);
  font-size: 11.5px;
}

.analytics-loading {
  opacity: .6;
  pointer-events: none;
}

.analytics-live-grid {
  margin-bottom: 10px;
}

.analytics-clean-grid {
  margin-bottom: 10px;
}

.analytics-section-title {
  margin: 12px 0 8px;
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
}

.analytics-hot-list {
  display: grid;
  gap: 6px;
  padding: 8px;
  max-height: 320px;
  overflow: auto;
}

.analytics-hot-item .status-chip {
  flex: none;
}

.source-card.realtime {
  border-left-color: #2b7a6f;
  background: #f8fbfb;
}

.source-card.suggestion {
  border-left-color: #f59e0b;
  background: #fffaf0;
}

.source-card.clean {
  border-left-color: #7c3aed;
  background: #fbfaff;
}

@media (max-width: 1180px) {
  .analytics-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .analytics-main-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .analytics-filter {
    justify-content: flex-start;
  }

  .analytics-custom-range {
    width: 100%;
  }

  .analytics-custom-range input {
    flex: 1;
    min-width: 0;
  }

  .analytics-kpi-grid {
    grid-template-columns: 1fr 1fr;
  }

  .analytics-kpi {
    min-height: 96px;
    padding: 11px;
  }

  .analytics-kpi-value {
    font-size: 22px;
  }

  .analytics-range-status {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }
}

body:not([data-section="chat"]) .list {
  background: #fff;
}

body:not([data-section="chat"]) .list > .session-item {
  border-left: 4px solid transparent;
}

body:not([data-section="chat"]) .list > .session-item:hover,
body:not([data-section="chat"]) .list > .session-item.active {
  border-left-color: var(--blue);
  background: #f7fbff;
}

body:not([data-section="chat"]) .detail .messages {
  min-height: 280px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

body:not([data-section="chat"]) .history-tools,
body:not([data-section="chat"]) .chat-tools {
  padding: 8px 0 0;
}

body:not([data-section="chat"]) .reminder-rule-grid {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.mobile-page {
  min-height: 100vh;
  padding: 0;
  background: #edf1f6;
}

.mobile-header {
  position: sticky;
  top: 0;
  z-index: 5;
  margin: 0;
  padding: 12px 12px 10px;
  background: linear-gradient(180deg, #101828 0, #172033 100%);
  color: #fff;
  box-shadow: 0 12px 24px rgba(16, 24, 40, 0.18);
}

.mobile-header strong {
  display: block;
  font-size: 18px;
}

.mobile-header .meta {
  margin-top: 3px;
  color: #b6c2d2;
}

.mobile-notify-toggle {
  width: 100%;
  min-height: 38px;
  margin-top: 10px;
  background: #243044;
  color: #d8dee9;
}

.mobile-notify-toggle.active {
  background: #ecfdf3;
  color: var(--green);
}

.mobile-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 10px;
  padding: 4px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.mobile-tabs button {
  min-height: 34px;
  border-radius: 6px;
  background: transparent;
  color: #d8dee9;
}

.mobile-tabs button.active {
  background: #1f6feb;
  color: #fff;
}

.mobile-section {
  display: none;
}

.mobile-section.active {
  display: grid;
  gap: 8px;
  padding: 8px;
}

.mobile-section > .panel {
  border-radius: 8px;
}

#m-sessions.active {
  grid-template-rows: auto minmax(0, 1fr);
}

#m-sessions > .panel:first-child {
  overflow: hidden;
  border-color: #d9a441;
}

#m-sessions > .panel:last-child {
  border-color: #8fb4e8;
}

#mSessionList {
  max-height: 34vh;
  overflow: auto;
}

.mobile-filter,
.mobile-actions,
.mobile-fields {
  display: grid;
  gap: 6px;
  padding: 8px;
  border-bottom: 1px solid var(--line);
}

.mobile-filter {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.mobile-actions {
  grid-template-columns: repeat(4, 1fr);
  background: #fbfcff;
}

.mobile-fields {
  grid-template-columns: 1fr 1fr;
}

.mobile-filter button,
.mobile-actions button {
  min-height: 34px;
  border-radius: 6px;
  background: #f1f5f9;
  color: var(--text);
  font-size: 13px;
}

.mobile-filter button.active {
  background: #dcecff;
  color: var(--blue);
  font-weight: 700;
  box-shadow: inset 0 -2px 0 var(--blue);
}

.mobile-fields input,
.mobile-fields select,
.mobile-note {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
}

.mobile-note {
  min-height: 58px;
  resize: vertical;
  border-left: 0;
  border-right: 0;
  border-radius: 0;
}

.mobile-profile {
  display: grid;
  gap: 5px;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  min-width: 0;
  background: #f2fbf6;
  border-left: 4px solid var(--green);
}

.mobile-profile strong {
  color: var(--text);
}

.mobile-profile > * {
  min-width: 0;
  overflow-wrap: anywhere;
}

.mobile-page .composer {
  position: sticky;
  bottom: 0;
  z-index: 4;
  background: #fff;
  box-shadow: 0 -12px 28px rgba(15, 23, 42, 0.08);
}

.mobile-page .composer textarea {
  min-height: 48px;
}

.mobile-quick {
  border-bottom: 1px solid var(--line);
  padding: 7px 8px;
}

.mobile-page .panel-head {
  min-height: 42px;
  padding: 8px 10px;
}

.mobile-page .session-item {
  gap: 4px;
  padding: 10px;
}

.mobile-page .session-item.active {
  border-left: 4px solid var(--blue);
}

.mobile-page .messages {
  height: 260px !important;
  padding: 9px;
}

.mobile-page .bubble {
  max-width: 74%;
}

.mobile-page .quick-replies button {
  min-height: 30px;
}

.mobile-drawer {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  align-items: end;
  background: rgba(15, 23, 42, 0.32);
}

.mobile-drawer[hidden] {
  display: none;
}

.mobile-drawer-panel {
  max-height: 78vh;
  overflow: hidden;
  border-radius: 12px 12px 0 0;
  background: #fff;
  box-shadow: 0 -18px 44px rgba(16, 24, 40, 0.22);
}

.mobile-drawer-body {
  display: grid;
  gap: 8px;
  max-height: calc(78vh - 52px);
  overflow: auto;
  padding: 10px;
}

.mobile-detail-card {
  display: grid;
  gap: 5px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcff;
  color: var(--muted);
  font-size: 12px;
}

.mobile-detail-card strong {
  color: var(--text);
}

.mobile-history-search {
  width: calc(100% - 16px);
  margin: 8px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

#mHistoryList {
  max-height: 34vh;
  overflow: auto;
}

.mobile-history-more {
  width: calc(100% - 16px);
  margin: 8px;
}

.mobile-history-detail {
  display: grid;
  gap: 0;
}

.mobile-history-block {
  display: grid;
  gap: 8px;
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
}

.mobile-history-block:last-child {
  border-bottom: 0;
}

.mobile-history-block > p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.mobile-history-messages {
  display: grid;
  gap: 7px;
}

.mobile-history-message {
  display: grid;
  gap: 4px;
  width: fit-content;
  max-width: 82%;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font-size: 13px;
  line-height: 1.5;
}

.mobile-history-message.operator,
.mobile-history-message.ai {
  justify-self: end;
  background: #edf9f3;
  border-color: #b7decf;
}

.mobile-history-message time {
  color: var(--muted);
  font-size: 11px;
}

.mobile-page .location-history-list {
  max-height: none;
}

.mobile-page .location-history-title time {
  width: 100%;
  margin-left: 0;
}

@media (max-width: 1100px) {
  .login-shell {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .login-brand-panel {
    gap: 42px;
    padding: 30px;
  }

  .login-copy h1 {
    font-size: 32px;
  }

  .login-card {
    padding: 30px;
  }

  .shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    min-height: auto;
    padding: 12px;
  }

  .brand {
    padding: 0 4px 10px;
  }

  .nav {
    display: flex;
    margin-top: 10px;
    overflow-x: auto;
  }

  .nav button {
    white-space: nowrap;
  }

  .sidebar-account {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin-top: 8px;
    padding: 8px 4px 0;
  }

  .sidebar-account > div {
    display: none;
  }

  .sidebar-account button {
    min-width: 108px;
    padding: 0 14px;
  }

  .cards {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

  .chat-focus-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .chat-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .chat-tools input {
    width: 100%;
  }

  .grid-chat {
    grid-template-columns: 1fr;
    height: auto;
  }

  body[data-section="chat"] {
    height: auto;
    overflow: auto;
  }

  body[data-section="chat"] .shell,
  body[data-section="chat"] .main,
  body[data-section="chat"] .chat-workbench {
    height: auto;
    overflow: visible;
  }

  body[data-section="chat"] .grid-chat {
    grid-template-columns: 1fr;
  }

  .chat-panel {
    min-height: 520px;
  }

  .two-col {
    grid-template-columns: 1fr;
  }

  .ai-status-cards,
  .ai-module-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .login-page {
    padding: 12px;
  }

  .login-brand-panel,
  .login-card {
    padding: 22px;
  }

  .login-copy h1 {
    font-size: 26px;
  }

  .chat-tools {
    flex-direction: column;
  }

  .chat-focus-strip {
    grid-template-columns: 1fr;
  }

  .chat-head,
  .chat-head-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .composer {
    grid-template-columns: 1fr;
  }

  .mobile-actions,
  .mobile-fields {
    grid-template-columns: repeat(2, 1fr);
  }

  .mobile-filter {
    grid-template-columns: repeat(2, 1fr);
  }

  .reminder-rule-grid {
    grid-template-columns: 1fr;
  }

  .deploy-access-grid,
  .ai-settings-grid,
  .ai-status-cards,
  .ai-module-grid,
  .widget-settings-grid,
  .deploy-actions {
    grid-template-columns: 1fr;
  }

  .reminder-rule-head {
    display: none;
  }

  .time-range {
    grid-template-columns: 1fr auto 1fr;
  }
}

.table tr.active-row td {
  background: #eef6ff;
}

.history-tools select {
  min-width: 140px;
}

.history-location-section {
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fbfcfe;
}

.history-location-head,
.location-history-title,
.location-history-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.history-location-head {
  justify-content: space-between;
  margin-bottom: 8px;
}

.history-location-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.location-history-list {
  display: grid;
  gap: 8px;
  max-height: 270px;
  overflow: auto;
}

.location-history-item {
  padding: 9px 10px;
  border: 1px solid #dce3ec;
  border-left: 3px solid #98a2b3;
  border-radius: 6px;
  background: #fff;
}

.location-history-item.precise {
  border-left-color: #2477d4;
}

.location-history-title time {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
}

.location-history-region {
  margin: 6px 0;
  color: #1d2939;
  font-size: 13px;
  line-height: 1.5;
}

.location-history-meta {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
}

.empty-state.compact {
  min-height: 42px;
  padding: 10px;
}
