:root {
  --brand: #2b7de9;
  --brand-soft: #eaf2fe;
  --bg: #f5f6f8;
  --card: #ffffff;
  --line: #e8eaed;
  --text: #1f2329;
  --text-2: #646a73;
  --text-3: #8f959e;
  --warn: #d97706;
  --warn-soft: #fef6e7;
  --ok: #16a34a;
  --ok-soft: #e8f7ee;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 13px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

/* 顶栏 */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

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

.logo {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  border-radius: 9px;
  background: var(--brand);
  color: #fff;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-text { min-width: 0; }
.brand-title { font-size: 14px; font-weight: 500; line-height: 1.3; }
.brand-sub {
  font-size: 11px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text-2);
  font-size: 15px;
  cursor: pointer;
}
.icon-btn:active { background: var(--bg); }

/* 主体 */
.main {
  flex: 1;
  padding: 12px;
  display: grid;
  gap: 12px;
  align-content: start;
}

/* 防 grid 子项把窄屏（侧边栏约 360px）撑出横向滚动 */
.main > * { min-width: 0; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}

.card-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-title .count { color: var(--text-3); font-weight: 400; }

/* 加载 */
.loading {
  padding: 40px 0;
  text-align: center;
  color: var(--text-3);
}
.spinner {
  width: 22px;
  height: 22px;
  margin: 0 auto 10px;
  border: 2px solid var(--line);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 客户卡 */
.customer { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: 12px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.customer-name { font-size: 15px; font-weight: 500; line-height: 1.3; }
.customer-meta { font-size: 12px; color: var(--text-3); margin-top: 2px; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
}
.tag.gray { background: #f2f3f5; color: var(--text-2); }

/* 指标 */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat {
  background: #fafbfc;
  border-radius: 10px;
  padding: 10px 8px;
  text-align: center;
}
.stat-value { font-size: 15px; font-weight: 500; line-height: 1.3; }
.stat-label { font-size: 11px; color: var(--text-3); margin-top: 2px; }

/* 列表 */
.list { display: grid; gap: 8px; }
.row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  border-radius: 10px;
  background: #fafbfc;
  cursor: default;
}
.row.clickable { cursor: pointer; }
.row.clickable:active { background: var(--brand-soft); }
.row-main { min-width: 0; }
.row-title { font-size: 13px; font-weight: 500; }
.row-sub { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.row-amount { font-size: 13px; font-weight: 500; white-space: nowrap; }

.badge {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.wait { background: var(--warn-soft); color: var(--warn); }

/* 话术 */
.script {
  border-left: 2px solid var(--brand);
  padding: 2px 0 2px 10px;
  cursor: pointer;
}
.script-title { font-size: 12px; font-weight: 500; color: var(--brand); }
.script-body {
  font-size: 12px;
  color: var(--text-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.script.open .script-body { -webkit-line-clamp: unset; }

/* 提示条 */
.notice {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 12px;
  line-height: 1.5;
}
.notice.info { background: var(--brand-soft); color: #1a5fb4; }
.notice.warn { background: var(--warn-soft); color: #8a5306; }
.notice.error { background: #fdecec; color: #b42318; }
.notice b { font-weight: 500; }

/* 空态 */
.empty {
  padding: 28px 12px;
  text-align: center;
  color: var(--text-3);
  font-size: 12px;
}

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
}
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn:active { opacity: .85; }

/* 调试栏 */
/* 备案号页脚（ICP备案要求：首页底部居中展示并链接至工信部） */
.site-foot {
  padding: 10px 12px 12px;
  text-align: center;
  font-size: 11px;
  line-height: 1.5;
}
.site-foot a {
  color: var(--muted, #8a9099);
  text-decoration: none;
  border-bottom: 1px dotted transparent;
}
.site-foot a:hover {
  color: var(--brand, #1f6feb);
  border-bottom-color: currentColor;
}

.debugbar {
  border-top: 1px solid var(--line);
  background: var(--card);
  padding: 8px 12px;
}
.debug-toggle {
  border: 0;
  background: none;
  color: var(--text-3);
  font-size: 11px;
  font-family: inherit;
  padding: 0;
  cursor: pointer;
}
.debug-log {
  margin: 8px 0 0;
  padding: 8px;
  max-height: 180px;
  overflow: auto;
  background: #f7f8fa;
  border-radius: 8px;
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-2);
  font-family: ui-monospace, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-all;
}

/* 宽屏（工作台入口 / 浏览器预览）：两列 */
@media (min-width: 620px) {
  .main {
    grid-template-columns: 1fr 1fr;
    max-width: 880px;
    margin: 0 auto;
    width: 100%;
  }
  .span-2 { grid-column: span 2; }
}
