:root {
  color: #15202b;
  background: #eef1f4;
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: #eef1f4;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px 18px;
  color: #f8fbff;
  background: #17212b;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  color: #17212b;
  background: #8fe3c6;
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  margin-top: 3px;
  color: #aebdca;
  font-size: 12px;
}

.sidebar nav {
  display: grid;
  gap: 6px;
}

.sidebar button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  color: #c4d0dc;
  background: transparent;
  text-align: left;
}

.sidebar button:hover,
.sidebar .nav-active {
  color: #ffffff;
  background: #263645;
}

.workspace {
  min-width: 0;
  padding: 26px;
}

.report-page,
.ai-page {
  display: none;
}

.workspace.report-mode .stats-grid,
.workspace.report-mode .content-grid,
.workspace.report-mode .chat-panel,
.workspace.report-mode .ai-page,
.workspace.ai-mode .stats-grid,
.workspace.ai-mode .content-grid,
.workspace.ai-mode .chat-panel,
.workspace.ai-mode .report-page {
  display: none;
}

.workspace.report-mode .report-page {
  display: grid;
}

.workspace.ai-mode .ai-page {
  display: grid;
}

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

.topbar p,
.panel p,
.stat-card p,
.stat-card span {
  margin: 0;
  color: #667380;
}

.topbar p {
  font-size: 13px;
}

.topbar h1 {
  margin: 5px 0 0;
  font-size: 28px;
  letter-spacing: 0;
}

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

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(340px, 34vw);
  height: 42px;
  padding: 0 12px;
  border: 1px solid #d8dee4;
  border-radius: 8px;
  background: #ffffff;
}

.search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: #15202b;
}

.primary-button,
.soft-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  border-radius: 8px;
  border: 1px solid transparent;
}

.primary-button {
  padding: 0 15px;
  color: #ffffff;
  background: #1c6b61;
}

.soft-button,
.icon-button {
  color: #2b3b49;
  border-color: #d8dee4;
  background: #ffffff;
}

.soft-button {
  padding: 0 12px;
}

.icon-button {
  width: 42px;
}

.compact {
  width: 34px;
  height: 34px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat-card,
.panel,
.chat-card {
  border: 1px solid #d9e0e6;
  border-radius: 8px;
  background: #ffffff;
}

.stat-card {
  display: flex;
  gap: 13px;
  min-height: 122px;
  padding: 18px;
}

.stat-icon {
  display: grid;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  color: #1c6b61;
  background: #dff5ef;
}

.stat-card strong {
  display: block;
  margin: 7px 0 5px;
  font-size: 24px;
}

.stat-card span {
  font-size: 12px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  margin-bottom: 18px;
  min-width: 0;
}

.panel {
  padding: 18px;
  min-width: 0;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel h2 {
  margin: 0 0 5px;
  font-size: 18px;
}

.panel p {
  font-size: 13px;
}

.account-table {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.campaign-section {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid #e1e6eb;
}

.campaign-head strong,
.campaign-head span {
  display: block;
}

.campaign-head span {
  margin-top: 4px;
  color: #667380;
  font-size: 12px;
}

.campaign-table {
  display: grid;
  gap: 2px;
  overflow-x: auto;
}

.connection-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 46px;
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid #d8dee4;
  border-radius: 8px;
  background: #f7f9fb;
}

.connection-banner strong,
.connection-banner span {
  display: block;
}

.connection-banner span {
  color: #667380;
  font-size: 12px;
  text-align: right;
}

.connection-banner.connected {
  border-color: #b9e7d9;
  background: #eef9f5;
}

.connection-banner.connected strong {
  color: #17664f;
}

.connection-banner.loading {
  border-color: #d8c88f;
  background: #fff8df;
}

.connection-banner.loading strong {
  color: #8a5708;
}

.connection-banner.disconnected {
  border-color: #f0c5bf;
  background: #fff0ee;
}

.connection-banner.disconnected strong {
  color: #9f2f29;
}

.table-row {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) 118px 92px 92px 82px 70px 72px 82px 82px 70px;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  padding: 0 10px;
  border-radius: 8px;
}

.table-row:not(.table-head):hover {
  background: #f5f8fa;
}

.table-head {
  min-height: 34px;
  color: #72808c;
  font-size: 12px;
}

.campaign-row {
  display: grid;
  grid-template-columns: minmax(260px, 1.5fr) 100px 92px 82px 70px 72px 82px 82px 70px 92px;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 0 10px;
  border-radius: 8px;
  font-size: 13px;
}

.campaign-row:not(.campaign-row-head):hover {
  background: #f5f8fa;
}

.campaign-row-head {
  min-height: 32px;
  color: #72808c;
  font-size: 12px;
}

.account-name strong,
.account-name small {
  display: block;
}

.account-name small,
.alert-text {
  margin-top: 4px;
  color: #71808d;
  font-size: 12px;
}

.effect-breakdown {
  max-width: 620px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.alert-text {
  display: block;
  color: #b24d17;
}

.status,
.stage,
.today-tag,
.unread {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status-正常 {
  color: #14624d;
  background: #dff5ef;
}

.status-观察 {
  color: #8a5708;
  background: #fff1cf;
}

.status-受限 {
  color: #9f2f29;
  background: #ffe1de;
}

.roi,
.effect {
  color: #1c6b61;
  font-weight: 800;
}

.effect small {
  display: block;
  margin-top: 3px;
  color: #71808d;
  font-size: 11px;
  font-weight: 700;
}

.report-panel {
  display: grid;
  gap: 12px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid #e1e6eb;
}

.report-head,
.report-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.report-head strong,
.report-head span {
  display: block;
}

.report-head span {
  margin-top: 4px;
  color: #667380;
  font-size: 12px;
}

.report-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.report-summary div {
  min-height: 68px;
  padding: 12px;
  border: 1px solid #d9e0e6;
  border-radius: 8px;
  background: #f7f9fb;
}

.report-summary span,
.report-summary strong,
.report-summary small {
  display: block;
}

.report-summary span {
  color: #667380;
  font-size: 12px;
}

.report-summary strong {
  margin-top: 6px;
  color: #15202b;
  font-size: 20px;
}

.report-summary small {
  margin-top: 4px;
  color: #7a8793;
  font-size: 11px;
}

.report-table {
  display: grid;
  gap: 4px;
  overflow-x: auto;
}

.report-note {
  padding: 10px;
  border-radius: 8px;
  color: #495866;
  background: #f7f9fb;
  font-size: 12px;
}

.report-row {
  display: grid;
  grid-template-columns: 72px 92px 70px 102px 82px 70px 70px 82px 70px 70px;
  align-items: center;
  gap: 12px;
  min-height: 46px;
  padding: 0 10px;
  border-radius: 8px;
  font-size: 13px;
}

.report-row:not(.report-row-head):hover {
  background: #f5f8fa;
}

.weekly-row {
  border: 1px solid #b9e7d9;
  background: #eef9f5;
}

.report-row-head {
  min-height: 32px;
  color: #72808c;
  font-size: 12px;
}

.segment-title {
  margin-top: 12px;
  padding: 8px 10px 2px;
  color: #263544;
  font-weight: 800;
}

.segment-row {
  display: grid;
  grid-template-columns: 100px 158px 92px 70px 102px 82px 70px 70px 82px;
  align-items: center;
  gap: 12px;
  min-height: 46px;
  padding: 0 10px;
  border-radius: 8px;
  font-size: 13px;
}

.segment-row:not(.segment-row-head):hover {
  background: #f5f8fa;
}

.segment-row-head {
  min-height: 32px;
  color: #72808c;
  font-size: 12px;
}

.empty-report {
  padding: 12px;
  border-radius: 8px;
  color: #667380;
  background: #f7f9fb;
}

.alert-list {
  display: grid;
  gap: 10px;
}

.alert-item {
  display: flex;
  gap: 10px;
  padding: 12px;
  border-radius: 8px;
  background: #f7f9fb;
}

.alert-item strong,
.alert-item span {
  display: block;
}

.alert-item span {
  margin-top: 4px;
  color: #6e7b86;
  font-size: 12px;
}

.danger {
  color: #a8322a;
}

.warning {
  color: #946007;
}

.success {
  color: #17664f;
}

.segmented {
  display: inline-flex;
  height: 38px;
  padding: 3px;
  border-radius: 8px;
  border: 1px solid #d8dee4;
  background: #f4f6f8;
}

.segmented button {
  min-width: 72px;
  border: 0;
  border-radius: 6px;
  color: #61707d;
  background: transparent;
}

.segmented .selected {
  color: #15202b;
  background: #ffffff;
  box-shadow: 0 1px 3px rgb(23 33 43 / 12%);
}

.chat-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.chat-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.sync-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 42px;
  margin: -2px 0 14px;
  padding: 8px 10px;
  border: 1px solid #d9e0e6;
  border-radius: 8px;
  background: #ffffff;
}

.chat-filter-bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.chat-filter-bar label {
  display: grid;
  gap: 6px;
}

.chat-filter-bar span {
  color: #667380;
  font-size: 12px;
  font-weight: 700;
}

.chat-filter-bar select {
  width: 100%;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid #d8dee4;
  border-radius: 8px;
  color: #15202b;
  background: #ffffff;
  font: inherit;
}

.chat-filter-summary {
  margin: -4px 0 12px;
  color: #667380;
  font-size: 12px;
  font-weight: 700;
}

.webhook-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 42px;
  margin: -2px 0 12px;
  padding: 8px 10px;
  border: 1px solid #d9e0e6;
  border-radius: 8px;
  color: #526170;
  background: #ffffff;
}

.webhook-strip strong {
  color: #263544;
}

.webhook-strip span {
  font-size: 12px;
}

.webhook-strip.active {
  border-color: #bce5d9;
  color: #276858;
  background: #eefaf6;
}

.toggle-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #263544;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.toggle-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-control span {
  position: relative;
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: #c9d2db;
  transition: background 0.2s ease;
}

.toggle-control span::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 2px rgb(23 33 43 / 24%);
  content: "";
  transition: transform 0.2s ease;
}

.toggle-control input:checked + span {
  background: #1c6b61;
}

.toggle-control input:checked + span::after {
  transform: translateX(16px);
}

.sync-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  color: #667380;
  font-size: 12px;
}

.sync-meta strong {
  color: #253545;
}

.chat-metrics div {
  min-height: 72px;
  padding: 12px;
  border: 1px solid #d9e0e6;
  border-radius: 8px;
  background: #f7f9fb;
}

.chat-metrics span,
.chat-metrics strong {
  display: block;
}

.chat-metrics span {
  color: #667380;
  font-size: 12px;
}

.chat-metrics strong {
  margin-top: 7px;
  color: #15202b;
  font-size: 22px;
}

.ai-panel {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid #d9e0e6;
  border-radius: 8px;
  background: #ffffff;
}

.ai-filter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.ai-filter-grid label {
  display: grid;
  gap: 6px;
}

.ai-filter-grid span {
  color: #667380;
  font-size: 12px;
  font-weight: 700;
}

.ai-filter-grid select {
  width: 100%;
  min-height: 42px;
  padding: 0 10px;
  border: 1px solid #d8dee4;
  border-radius: 8px;
  color: #15202b;
  background: #ffffff;
  font: inherit;
}

.ai-panel > div:first-child {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ai-panel strong,
.ai-panel span {
  display: block;
}

.ai-panel span,
.ai-panel p,
.ai-score small {
  color: #667380;
  font-size: 12px;
}

.ai-panel p {
  margin: 0;
}

.ai-result {
  display: grid;
  gap: 12px;
}

.ai-history-list {
  display: grid;
  gap: 10px;
}

.ai-history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid #e0e6eb;
  border-radius: 8px;
  background: #f8fafb;
}

.ai-history-item strong,
.ai-history-item span {
  display: block;
}

.ai-history-item span {
  margin-top: 4px;
  color: #667380;
  font-size: 12px;
}

.ai-history-item p {
  display: -webkit-box;
  margin-top: 7px;
  overflow: hidden;
  color: #344250;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.ai-score {
  display: grid;
  grid-template-columns: 90px 110px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
  background: #eef9f5;
}

.ai-score strong {
  color: #17664f;
  font-size: 24px;
}

.ai-summary,
.ai-warning {
  padding: 10px;
  border-radius: 8px;
  color: #263544;
  background: #f7f9fb;
  line-height: 1.5;
}

.ai-warning {
  color: #9f2f29;
  background: #fff0ee;
}

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

.ai-columns section {
  min-width: 0;
  padding: 12px;
  border: 1px solid #d9e0e6;
  border-radius: 8px;
  background: #f7f9fb;
}

.ai-columns h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.ai-columns ul {
  display: grid;
  gap: 7px;
  margin: 0;
  padding-left: 18px;
  color: #344554;
  font-size: 13px;
  line-height: 1.45;
}

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

.ai-customer-findings h3 {
  margin: 0;
  font-size: 15px;
}

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

.ai-customer-findings article {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 12px;
  border: 1px solid #d9e0e6;
  border-radius: 8px;
  background: #f7f9fb;
}

.ai-customer-findings article > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.ai-customer-findings article strong,
.ai-customer-findings article span {
  display: block;
}

.ai-customer-findings article span {
  color: #667380;
  font-size: 12px;
  text-align: right;
}

.ai-customer-findings p {
  margin: 0;
  color: #263544;
  line-height: 1.45;
}

.ai-customer-findings ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 18px;
  color: #344554;
  font-size: 13px;
  line-height: 1.45;
}

.chat-card {
  display: grid;
  gap: 12px;
  min-height: 245px;
  padding: 15px;
}

.chat-card-head,
.chat-footer,
.chat-meta,
.next-action {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-card-head,
.chat-footer {
  justify-content: space-between;
}

.chat-card-head strong,
.chat-card-head span {
  display: block;
}

.chat-card-head span,
.chat-meta span,
.chat-footer span {
  color: #687682;
  font-size: 12px;
}

.chat-meta {
  flex-wrap: wrap;
}

.stage-0 {
  color: #1f5d8d;
  background: #e1f0ff;
}

.stage-1 {
  color: #4f5f0f;
  background: #f0f4c9;
}

.stage-2 {
  color: #715611;
  background: #fff1cf;
}

.stage-3 {
  color: #8f3b6b;
  background: #ffe1ef;
}

.stage-4 {
  color: #17664f;
  background: #dff5ef;
}

.today-tag {
  color: #1f5d8d;
  background: #e1f0ff;
}

.realtime-tag {
  color: #14624d;
  background: #dff5ef;
}

.message {
  min-height: 44px;
  margin: 0;
  color: #243441;
  line-height: 1.5;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  word-break: break-word;
}

.next-action {
  min-height: 42px;
  padding: 10px;
  border-radius: 8px;
  color: #1c6b61;
  background: #eef9f5;
  font-size: 13px;
}

.chat-footer strong {
  color: #15202b;
}

.unread {
  color: #ffffff !important;
  background: #d85d3f;
}

@media (max-width: 1180px) {
  .stats-grid,
  .chat-board,
  .chat-metrics,
  .report-summary,
  .ai-filter-grid,
  .ai-columns,
  .ai-customer-findings > div {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 14px;
  }

  .sidebar nav {
    grid-template-columns: repeat(5, minmax(42px, 1fr));
    overflow-x: auto;
  }

  .sidebar button {
    justify-content: center;
    min-width: 42px;
    padding: 0;
    font-size: 0;
  }

  .workspace {
    padding: 18px;
  }

  .topbar,
  .top-actions,
  .panel-head,
  .panel-actions,
  .report-head {
    align-items: stretch;
    flex-direction: column;
  }

  .search {
    width: 100%;
  }

  .primary-button,
  .soft-button {
    width: 100%;
  }

  .segmented {
    width: 100%;
  }

  .segmented button {
    flex: 1;
  }

  .connection-banner {
    align-items: flex-start;
    flex-direction: column;
  }

  .connection-banner span {
    text-align: left;
  }

  .sync-strip,
  .webhook-strip,
  .sync-meta {
    align-items: flex-start;
    flex-direction: column;
  }

  .sync-meta {
    gap: 4px;
  }

  .stats-grid,
  .chat-board,
  .chat-metrics,
  .chat-filter-bar,
  .report-summary,
  .ai-filter-grid,
  .ai-columns,
  .ai-customer-findings > div {
    grid-template-columns: 1fr;
  }

  .ai-panel > div:first-child,
  .ai-score {
    align-items: flex-start;
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .account-table,
  .campaign-table {
    overflow-x: auto;
  }

  .table-row {
    min-width: 1040px;
  }

  .campaign-row {
    min-width: 1060px;
  }

  .report-row {
    min-width: 860px;
  }
}
