* {
  box-sizing: border-box;
}

:root {
  color-scheme: light;
  --bg: #eef2f5;
  --surface: #ffffff;
  --surface-soft: #f7f9fb;
  --surface-raised: #ffffff;
  --line: #d9e1e7;
  --line-strong: #bdc9d2;
  --text: #17212b;
  --text-soft: #364756;
  --muted: #6b7885;
  --muted-soft: #8a97a3;
  --accent: #176b57;
  --accent-hover: #0f5544;
  --accent-soft: #e5f3ee;
  --accent-line: #9bcdbd;
  --blue: #235d8f;
  --blue-soft: #e7f0f8;
  --warning: #8a5b12;
  --warning-bg: #fff7e6;
  --danger: #a33131;
  --danger-bg: #fff1f1;
  --shadow-soft: 0 12px 28px rgba(23, 33, 43, 0.08);
  --shadow-pop: 0 22px 52px rgba(23, 33, 43, 0.18);
  --radius: 8px;
  --topbar-height: 72px;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
  color: var(--text);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  text-rendering: optimizeLegibility;
}

.is-hidden {
  display: none !important;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 4px;
  color: var(--text);
  font-size: 22px;
  font-weight: 760;
  line-height: 1.2;
}

h2 {
  margin-bottom: 0;
  color: var(--text);
  font-size: 15px;
  font-weight: 720;
  line-height: 1.3;
}

h3 {
  margin-bottom: 7px;
  color: var(--text);
  font-size: 13px;
  font-weight: 720;
  line-height: 1.35;
}

p {
  margin-bottom: 0;
  line-height: 1.55;
}

button,
select,
.input,
textarea {
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  font: inherit;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: max-content;
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
  padding: 8px 13px;
  font-weight: 680;
  cursor: pointer;
  white-space: nowrap;
  transition: background 140ms ease, border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

button:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: 0 6px 16px rgba(23, 107, 87, 0.18);
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  cursor: wait;
  opacity: 0.64;
  box-shadow: none;
}

.button-secondary {
  background: var(--surface);
  color: var(--text-soft);
  border-color: var(--line);
}

.button-secondary:hover {
  background: var(--surface-soft);
  color: var(--text);
  border-color: var(--line-strong);
  box-shadow: none;
}

.button-danger {
  background: var(--surface);
  color: var(--danger);
  border-color: #efb3b3;
}

.button-danger:hover {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: var(--danger);
  box-shadow: none;
}

.login-view {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(238, 242, 245, 0.92)),
    var(--bg);
}

.login-panel {
  display: grid;
  width: min(410px, 100%);
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
  padding: 28px;
}

.login-panel h1 {
  font-size: 24px;
}

.login-panel p {
  color: var(--muted);
  font-size: 14px;
}

.login-panel label {
  display: grid;
  gap: 7px;
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 650;
}

.login-error {
  min-height: 20px;
  color: var(--danger) !important;
  font-size: 13px !important;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  min-height: var(--topbar-height);
  padding: 13px 18px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
}

.topbar-title {
  min-width: 0;
}

.topbar-title p,
.muted,
.meta-text,
.empty-state {
  color: var(--muted);
  font-size: 13px;
}

.topbar-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.page-tabs {
  display: flex;
  gap: 4px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
}

.page-tab {
  min-height: 30px;
  background: transparent;
  color: var(--text-soft);
  border-color: transparent;
  border-radius: 999px;
  padding: 5px 12px;
  box-shadow: none;
}

.page-tab:hover {
  background: var(--surface);
  color: var(--text);
  border-color: transparent;
  box-shadow: none;
}

.page-tab.active {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

.top-actions,
.user-area,
.dialog-actions {
  display: flex;
  gap: 8px;
}

.top-actions button {
  min-height: 36px;
}

#salesPlanBtn {
  background: var(--blue);
  border-color: var(--blue);
}

#salesPlanBtn:hover {
  background: #1b4d78;
  border-color: #1b4d78;
  box-shadow: 0 6px 16px rgba(35, 93, 143, 0.18);
}

.user-area {
  align-items: center;
  min-height: 38px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text-soft);
  padding: 4px 5px 4px 12px;
  font-size: 13px;
  white-space: nowrap;
}

.user-area .button-secondary {
  min-height: 29px;
  border-radius: 999px;
  padding: 5px 10px;
}

.layout {
  display: grid;
  grid-template-columns: 292px minmax(390px, 1fr) 380px;
  height: calc(100vh - var(--topbar-height));
  min-height: 0;
}

.app-page.is-hidden {
  display: none;
}

.customer-panel,
.coach-panel {
  overflow: auto;
  background: var(--surface);
  padding: 15px;
}

.customer-panel {
  border-right: 1px solid var(--line);
}

.coach-panel {
  border-left: 1px solid var(--line);
}

.conversation-panel {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  background: #f3f6f8;
}

.panel-header,
.conversation-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.panel-header h2 {
  letter-spacing: 0;
}

.conversation-header {
  min-height: 76px;
  margin: 0;
  padding: 14px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.conversation-header > div {
  min-width: 0;
}

.conversation-header-actions {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 8px;
}

.conversation-header-actions .button-secondary {
  min-width: 88px;
  min-height: 34px;
  padding: 6px 14px;
}

.conversation-header-actions .customer-delete-button {
  color: var(--danger);
  border-color: #efb3b3;
}

.conversation-header-actions .customer-delete-button:hover {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: var(--danger);
}

#activeCustomerName,
#activeCustomerNotes {
  overflow: hidden;
  text-overflow: ellipsis;
}

#activeCustomerName {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 7px;
  white-space: normal;
}

#activeCustomerName .customer-tags {
  flex: 0 1 auto;
  max-width: 100%;
  overflow: visible;
  white-space: normal;
  flex-wrap: wrap;
}

#activeCustomerName .customer-tag {
  flex: 0 0 auto;
  max-width: none;
  overflow: visible;
  text-overflow: clip;
}

#activeCustomerNotes {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.input,
textarea,
select {
  width: 100%;
  background: var(--surface);
  color: var(--text);
  padding: 9px 11px;
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.input::placeholder,
textarea::placeholder {
  color: var(--muted-soft);
}

.input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(23, 107, 87, 0.12);
}

textarea {
  line-height: 1.5;
}

.customer-list {
  display: grid;
  gap: 9px;
  margin-top: 13px;
}

.customer-card {
  display: grid;
  grid-template-rows: auto auto auto;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 76px;
  gap: 5px;
  align-items: start;
  justify-content: stretch;
  justify-items: stretch;
  background: var(--surface-soft);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px;
  text-align: left;
  white-space: normal;
  box-shadow: none;
  overflow: hidden;
}

.customer-card:hover {
  background: #f0f6f5;
  border-color: var(--accent-line);
  box-shadow: none;
}

.customer-card.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}

.customer-card strong,
.customer-card small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.customer-title-row {
  display: flex;
  align-items: center;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  gap: 6px;
  overflow: hidden;
}

.customer-card strong {
  flex: 0 1 auto;
  max-width: 112px;
  min-width: 0;
  color: var(--text);
  font-size: 14px;
  white-space: nowrap;
}

.customer-tags {
  display: inline-flex;
  align-items: center;
  flex: 1 1 0;
  max-width: 100%;
  min-width: 0;
  gap: 4px;
  overflow: hidden;
  white-space: nowrap;
}

.customer-tag {
  display: inline-flex;
  align-items: center;
  flex: 0 1 auto;
  max-width: 72px;
  min-height: 20px;
  border: 1px solid var(--accent-line);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 720;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.customer-tag-label {
  flex: 0 0 auto;
  color: var(--blue);
  font-size: 12px;
  font-weight: 720;
  line-height: 1.2;
  white-space: nowrap;
}

.customer-tag.more {
  flex: 0 0 auto;
  max-width: none;
  background: var(--surface);
  color: var(--muted);
  border-color: var(--line);
}

.customer-tag.ai {
  border-color: #c8d9e8;
  background: var(--blue-soft);
  color: var(--blue);
}

.customer-card small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.38;
}

.customer-owner {
  color: var(--accent) !important;
  font-weight: 700;
}

.customer-card:hover strong,
.customer-card.active strong {
  color: #0f5544;
}

.message-list {
  flex: 1;
  overflow: auto;
  min-height: 0;
  padding: 18px;
}

.ai-coach-notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  position: sticky;
  top: 10px;
  z-index: 6;
  margin: 12px 18px 0;
  border: 2px solid #d49a1d;
  border-radius: var(--radius);
  background: #fff4d6;
  color: #7a4d00;
  box-shadow: 0 16px 34px rgba(122, 77, 0, 0.2);
  padding: 12px 14px;
}

.ai-coach-notice.coach-notice-pulse {
  animation: coachNoticePulse 1.6s ease 2;
}

.ai-coach-notice strong {
  white-space: nowrap;
  font-size: 15px;
}

.ai-coach-notice span {
  min-width: 0;
  color: #5d420f;
}

@keyframes coachNoticePulse {
  0% {
    transform: scale(1);
    box-shadow: 0 16px 34px rgba(122, 77, 0, 0.2);
  }
  45% {
    transform: scale(1.015);
    box-shadow: 0 18px 38px rgba(122, 77, 0, 0.32), 0 0 0 6px rgba(212, 154, 29, 0.16);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 16px 34px rgba(122, 77, 0, 0.2);
  }
}

.message {
  width: fit-content;
  max-width: min(76%, 720px);
  margin-bottom: 11px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px 12px;
  line-height: 1.58;
  white-space: normal;
  word-break: break-word;
  box-shadow: 0 4px 12px rgba(23, 33, 43, 0.04);
}

.message.sales {
  margin-left: auto;
  background: var(--accent-soft);
  border-color: var(--accent-line);
}

.message-meta {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.message-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 5px;
}

.message-topline .message-meta {
  margin-bottom: 0;
}

.message-delete-button {
  display: inline-grid;
  place-items: center;
  flex: 0 0 24px;
  width: 22px;
  height: 22px;
  min-width: 22px;
  min-height: 22px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  padding: 0;
  font-size: 18px;
  font-weight: 520;
  line-height: 1;
  cursor: pointer;
  opacity: 1;
  box-shadow: none;
  transform: none;
  transition: opacity 120ms ease, color 120ms ease, background 120ms ease, border-color 120ms ease;
}

.message-delete-button:focus-visible {
  outline: 2px solid rgba(193, 77, 65, 0.22);
  outline-offset: 2px;
}

.message-delete-button:hover {
  background: rgba(193, 77, 65, 0.1);
  border-color: rgba(193, 77, 65, 0.2);
  box-shadow: none;
  color: var(--danger);
  transform: none;
}

.message-delete-button:active {
  transform: none;
}

.composer,
.wechat-composer {
  display: grid;
  gap: 8px;
  padding: 10px 12px;
  background: #f6f6f6;
  border-top: 1px solid #d8dde3;
}

.wechat-composer-main {
  display: block;
}

.wechat-composer-main textarea {
  width: 100%;
  min-height: 40px;
  max-height: 116px;
  resize: vertical;
  border-radius: 8px;
  background: #ffffff;
  line-height: 1.45;
  padding: 9px 11px;
}

.composer-tool-button,
.composer-primary-button {
  min-height: 40px;
  border-radius: 8px;
  padding: 0 14px;
  white-space: nowrap;
}

.wechat-composer-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.wechat-composer-actions select {
  flex: 0 0 auto;
  width: 88px;
  height: 40px;
  border-radius: 8px;
  background: #ffffff;
  font-weight: 700;
  margin-right: auto;
}

.composer-tool-button {
  background: #ffffff;
  border: 1px solid #cfd7df;
  color: var(--text);
  box-shadow: none;
}

.composer-primary-button {
  background: #1aad19;
  border: 1px solid #159a15;
  color: #ffffff;
  box-shadow: 0 6px 16px rgba(26, 173, 25, 0.18);
}

.composer-tool-button:hover {
  background: #fdfdfd;
  border-color: #b9c4ce;
  box-shadow: none;
}

.composer-primary-button:hover {
  background: #159a15;
  border-color: #128812;
}

.screenshot-preview-panel {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 12px 14px;
  background: #fff9ec;
  border-top: 1px solid #ead3a4;
}

.screenshot-preview-list {
  display: grid;
  gap: 8px;
}

.screenshot-preview-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
}

.screenshot-preview-row textarea {
  min-height: 48px;
  resize: vertical;
}

.screenshot-preview-warnings {
  display: grid;
  gap: 4px;
}

.screenshot-preview-warnings p {
  color: var(--warning);
  font-size: 12px;
}

.screenshot-preview-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.coach-content {
  display: grid;
  gap: 10px;
}

.coach-card {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}

.coach-card:first-child {
  background: #f0f8f5;
  border-color: var(--accent-line);
  box-shadow: inset 3px 0 0 var(--accent);
}

.coach-panel-pulse .coach-card:first-child {
  animation: coachPulse 1.4s ease;
}

@keyframes coachPulse {
  0% {
    box-shadow: inset 3px 0 0 var(--accent), 0 0 0 0 rgba(23, 107, 87, 0.3);
  }
  45% {
    box-shadow: inset 3px 0 0 var(--accent), 0 0 0 7px rgba(23, 107, 87, 0.12);
  }
  100% {
    box-shadow: inset 3px 0 0 var(--accent), 0 0 0 0 rgba(23, 107, 87, 0);
  }
}

.coach-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.coach-card-header h3 {
  min-width: 0;
}

.coach-copy-button {
  min-height: 28px;
  padding: 5px 9px;
  font-size: 12px;
  flex: 0 0 auto;
}

.coach-card p,
.coach-card li {
  color: var(--text-soft);
  font-size: 14px;
}

.coach-card ul {
  margin: 0;
  padding-left: 18px;
}

.knowledge-references {
  display: grid;
  gap: 7px;
  padding-left: 0 !important;
  list-style: none;
}

.knowledge-references li {
  display: grid;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 9px;
}

.knowledge-references strong {
  color: var(--text);
  font-size: 13px;
}

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

.coach-card.warning {
  background: var(--warning-bg);
  border-color: #f0d596;
  box-shadow: inset 3px 0 0 #d79a2b;
}

.coach-card.warning h3,
.coach-card.warning p {
  color: var(--warning);
}

.coach-card.danger {
  background: var(--danger-bg);
  border-color: #efb3b3;
  box-shadow: inset 3px 0 0 var(--danger);
}

.coach-card.danger h3,
.coach-card.danger p {
  color: var(--danger);
}

.knowledge-panel {
  display: grid;
  gap: 16px;
}

.knowledge-page,
.reviews-page,
.members-page,
.security-page,
.ai-settings-page {
  height: calc(100vh - var(--topbar-height));
  overflow: auto;
  padding: 18px;
}

.knowledge-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}

.members-panel {
  display: grid;
  gap: 16px;
}

.members-workspace {
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(420px, 1fr);
  gap: 14px;
  max-width: 1320px;
  width: 100%;
  margin: 0 auto;
}

.ai-settings-workspace {
  grid-template-columns: minmax(320px, 460px) minmax(360px, 1fr);
}

.security-workspace {
  grid-template-columns: 1fr;
}

.knowledge-tool-panel,
.knowledge-list-panel {
  display: grid;
  align-content: start;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 14px;
}

.knowledge-review-layout {
  display: grid;
  grid-template-columns: minmax(560px, 1fr) minmax(320px, 390px);
  gap: 14px;
  max-width: 1320px;
  width: 100%;
  margin: 0 auto;
  align-items: start;
}

.knowledge-review-list {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.knowledge-tab-bar {
  display: flex;
  gap: 8px;
  padding: 4px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.knowledge-tab-bar button {
  flex: 1;
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  box-shadow: none;
}

.knowledge-tab-bar button.active {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text);
  box-shadow: var(--shadow-soft);
}

.knowledge-tab-panel {
  display: grid;
  gap: 12px;
}

.system-knowledge-panel {
  display: grid;
  gap: 10px;
  background: #f7fbff;
  border: 1px solid #c9dced;
  border-radius: var(--radius);
  padding: 12px;
}

.system-knowledge-list {
  gap: 8px;
}

.system-knowledge-item {
  background: #ffffff;
  border-color: #b9d4e8;
  box-shadow: inset 3px 0 0 var(--blue);
}

.knowledge-review-side {
  display: grid;
  gap: 12px;
  position: sticky;
  top: 18px;
  align-self: start;
  max-height: calc(100vh - var(--topbar-height) - 36px);
  overflow: auto;
  padding-right: 2px;
}

.knowledge-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.knowledge-source-filter-bar {
  margin-top: 8px;
}

.knowledge-filter-bar button {
  min-height: 32px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 5px 11px;
  font-size: 13px;
  box-shadow: none;
}

.knowledge-filter-bar button.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-strong);
}

.knowledge-form {
  display: grid;
  gap: 8px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
}

.knowledge-upload-form {
  margin-top: 10px;
}

.knowledge-upload-form select {
  cursor: pointer;
}

.knowledge-upload-form .primary-button {
  width: 100%;
}

.knowledge-upload-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.knowledge-form textarea {
  min-height: 180px;
  resize: vertical;
}

.knowledge-list {
  display: grid;
  gap: 10px;
  align-content: start;
}

.knowledge-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 14px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}

.knowledge-item-open {
  cursor: pointer;
  border-radius: 6px;
}

.knowledge-item-open:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.member-item {
  display: grid;
  gap: 6px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
}

.member-item-header,
.member-item-actions,
.member-role-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.knowledge-item-main {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.knowledge-item-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.knowledge-item strong,
.knowledge-item p,
.member-item strong {
  overflow-wrap: anywhere;
}

.knowledge-item strong {
  color: var(--text);
  font-size: 14px;
}

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

.knowledge-item p {
  margin: 0;
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.knowledge-segments {
  display: grid;
  gap: 8px;
}

.knowledge-item .knowledge-segment-old,
.knowledge-item .knowledge-segment-new {
  display: block;
  margin: 0;
  padding: 8px 10px;
  border-left: 3px solid #cbd5e1;
  border-radius: 6px;
  background: #f8fafc;
  color: var(--text-soft);
  -webkit-line-clamp: unset;
  overflow: visible;
}

.knowledge-item .knowledge-segment-new {
  border-left-color: #10b981;
  background: #ecfdf5;
  color: var(--text);
}

.knowledge-item-meta,
.knowledge-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.knowledge-tags span,
.knowledge-status {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  padding: 2px 7px;
}

.knowledge-status-draft {
  border-color: #e6c56f;
  background: var(--warning-bg);
  color: var(--warning) !important;
}

.knowledge-status-published {
  border-color: #9cd3c1;
  background: #e9f8f2;
  color: var(--accent-strong) !important;
}

.knowledge-status-archived {
  background: #eef1f4;
}

.knowledge-item-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  min-width: 170px;
}

.knowledge-detail-dialog {
  max-height: calc(100dvh - 32px);
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}

.knowledge-detail-dialog .dialog-title-row {
  align-items: flex-start;
}

.knowledge-detail-dialog .dialog-title-row > div {
  min-width: 0;
}

#knowledgeDetailTitle,
#knowledgeDetailMeta {
  overflow-wrap: anywhere;
}

.knowledge-detail-content {
  display: grid;
  gap: 12px;
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
}

.knowledge-detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.knowledge-detail-tags {
  margin-bottom: 2px;
}

.knowledge-detail-body {
  min-height: 220px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 12px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.65;
}

.knowledge-detail-segments {
  display: grid;
  gap: 10px;
}

.knowledge-detail-segment {
  border-left: 3px solid #cbd5e1;
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 10px 12px;
}

.knowledge-detail-segment p {
  margin: 6px 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.65;
}

.knowledge-import-drawer {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 12px 14px;
}

.knowledge-import-drawer summary {
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.knowledge-import-drawer[open] {
  align-self: start;
}

.knowledge-import-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid #9cc7e8;
  border-radius: var(--radius);
  background: #eff7ff;
  color: #174a73;
  padding: 10px 11px;
  font-size: 13px;
  line-height: 1.45;
}

.knowledge-import-progress p {
  margin: 2px 0 0;
  color: #3c6382;
}

.progress-spinner {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  border: 2px solid rgba(25, 118, 176, 0.22);
  border-top-color: #1976b0;
  border-radius: 50%;
  animation: progressSpin 0.8s linear infinite;
}

.progress-spinner-large {
  width: 30px;
  height: 30px;
  border-width: 3px;
}

.knowledge-import-overlay {
  position: fixed;
  inset: 0;
  z-index: 19;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.32);
  backdrop-filter: blur(2px);
}

.knowledge-import-overlay-card {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow: var(--shadow-pop);
  padding: 20px;
  text-align: center;
}

.knowledge-import-overlay-card h2 {
  margin: 12px 0 6px;
  font-size: 18px;
}

.knowledge-import-overlay-card p {
  margin: 0;
  color: var(--text);
  font-weight: 700;
}

.knowledge-import-overlay-card span {
  display: block;
  margin-top: 8px;
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.5;
}

@keyframes progressSpin {
  to {
    transform: rotate(360deg);
  }
}

.members-list {
  display: grid;
  gap: 9px;
  align-content: start;
}

.backup-list {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.backup-list .member-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.backup-list .member-item-header {
  min-width: min(100%, 260px);
  flex: 1 1 320px;
}

.backup-list .member-item-actions {
  flex: 0 1 auto;
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
}

.member-item[data-status="disabled"] {
  opacity: 0.68;
}

.member-item[data-backup-current="true"] {
  border-color: var(--accent);
}

.member-item small {
  color: var(--muted);
}

.warning-text {
  color: var(--danger);
  line-height: 1.55;
}

.ai-settings-note {
  display: grid;
  gap: 10px;
  color: var(--text-soft);
  font-size: 14px;
  line-height: 1.7;
}

.ai-settings-note p {
  margin: 0;
}

.member-role-row {
  justify-content: flex-start;
  flex-wrap: wrap;
}

.member-role-select {
  min-width: 120px;
}

.member-item-actions {
  justify-content: flex-start;
  flex-wrap: wrap;
}

dialog {
  width: min(480px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
}

dialog::backdrop {
  background: rgba(17, 24, 31, 0.42);
}

.dialog-card {
  display: grid;
  gap: 13px;
  background: var(--surface);
  padding: 20px;
}

.dialog-card label {
  display: grid;
  gap: 7px;
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 650;
}

.dialog-card textarea {
  min-height: 92px;
  resize: vertical;
}

.dialog-actions {
  justify-content: flex-end;
  margin-top: 2px;
}

#aiTaskDialog {
  width: min(820px, calc(100vw - 32px));
}

#customerAiChatDialog {
  width: min(760px, calc(100vw - 32px));
}

#knowledgeDetailDialog {
  width: min(860px, calc(100vw - 32px));
}

.ai-task-dialog {
  max-height: calc(100dvh - 32px);
  grid-template-rows: auto auto minmax(0, 1fr);
  overflow: hidden;
}

.customer-ai-chat-dialog {
  max-height: calc(100dvh - 32px);
  grid-template-rows: auto minmax(260px, 1fr) auto;
  overflow: hidden;
}

.dialog-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dialog-title-row h2 {
  min-width: 0;
}

.ai-task-list {
  display: grid;
  gap: 10px;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.customer-ai-chat-list {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f6f8fa;
  padding: 12px;
}

.customer-ai-chat-message {
  display: grid;
  gap: 7px;
  max-width: 86%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 10px 12px;
}

.customer-ai-chat-message.user {
  justify-self: end;
  border-color: rgba(15, 118, 90, 0.24);
  background: #e8f7ef;
}

.customer-ai-chat-message.assistant {
  justify-self: start;
}

.customer-ai-chat-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.customer-ai-chat-meta strong {
  color: var(--text);
  font-size: 13px;
}

.customer-ai-chat-meta span {
  margin-right: auto;
}

.ai-chat-copy-button {
  min-height: 28px;
  padding: 4px 9px;
}

.customer-ai-chat-message p {
  margin: 0;
  color: var(--text);
  line-height: 1.65;
  white-space: pre-wrap;
}

.customer-ai-chat-composer {
  display: grid;
  gap: 10px;
}

.customer-ai-chat-composer textarea {
  min-height: 86px;
  resize: vertical;
}

.ai-task-item {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.7);
  padding: 12px;
}

.ai-task-item div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.ai-task-item span,
.ai-task-item small {
  color: var(--muted);
  font-size: 12px;
}

.ai-task-item p {
  max-height: 220px;
  overflow: auto;
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.empty-state {
  padding: 11px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.64);
  line-height: 1.55;
}

.app-toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: min(360px, calc(100vw - 36px));
  background: var(--text);
  color: #ffffff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.45;
}

.app-toast-success {
  background: var(--accent);
}

.app-toast-error {
  background: var(--danger);
}

.app-toast-loading {
  background: var(--blue);
}

@media (max-width: 1180px) {
  .layout {
    grid-template-columns: 270px minmax(330px, 1fr);
  }

  .knowledge-review-layout {
    grid-template-columns: 1fr;
  }

  .members-workspace {
    grid-template-columns: 1fr;
  }

  .knowledge-review-side {
    position: static;
  }

  .coach-panel {
    grid-column: 1 / -1;
    border-top: 1px solid var(--line);
    border-left: 0;
  }
}

@media (max-width: 780px) {
  :root {
    --topbar-height: auto;
  }

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

  .topbar-controls,
  .page-tabs,
  .user-area {
    align-items: stretch;
    flex-direction: column;
  }

  .page-tabs {
    border-radius: var(--radius);
  }

  .user-area {
    border-radius: var(--radius);
    padding: 9px;
  }

  .top-actions,
  .user-area,
  .dialog-actions {
    flex-wrap: wrap;
  }

  .top-actions button,
  .dialog-actions button {
    flex: 1 1 140px;
  }

  .layout {
    display: block;
    height: auto;
    min-height: auto;
  }

  .knowledge-page,
  .reviews-page,
  .members-page,
  .security-page,
  .ai-settings-page {
    height: auto;
    padding: 14px;
  }

  .knowledge-page-header,
  .knowledge-review-layout,
  .members-workspace {
    display: grid;
    grid-template-columns: 1fr;
  }

  .knowledge-item {
    grid-template-columns: 1fr;
  }

  .knowledge-item-actions {
    justify-content: flex-start;
    min-width: 0;
  }

  .customer-panel,
  .coach-panel {
    max-height: none;
    border-right: 0;
    border-left: 0;
    border-bottom: 1px solid var(--line);
  }

  .conversation-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .conversation-header-actions {
    width: 100%;
    justify-content: space-between;
  }

  #activeCustomerName {
    white-space: normal;
  }

  .message-list {
    min-height: 330px;
  }

  .ai-coach-notice {
    align-items: stretch;
    flex-direction: column;
  }

  .message {
    max-width: 92%;
  }

  .wechat-composer-actions {
    justify-content: flex-end;
    flex-wrap: wrap;
  }

  .screenshot-preview-row {
    grid-template-columns: 1fr;
  }
}

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

  .login-panel {
    padding: 22px;
  }
}
