/**
 * APP 主 Tab 壳：工作台 / 客户 / 我的 + 底部导航
 * 依赖 crm-design-system.css、crm-app.css；容器 .phone.theme-app.app-main-shell
 * 用法见 crm-app-main.js · UI设计规范 §6.3
 */

.app-main-shell {
  display: flex;
  flex-direction: column;
  background: var(--bg-page);
}
.app-main-shell .app-main-body {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
}
.app-main-shell .app-main-scroll {
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(56px + var(--safe-bottom));
  scrollbar-width: none;
}
.app-main-shell .app-main-scroll::-webkit-scrollbar { display: none; }

/* 状态栏（渐变顶栏页） */
.app-main-shell .status-bar.transparent {
  background: transparent;
  color: #fff;
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  z-index: 6;
}

/* —— 底部主 Tab —— */
.main-tabbar {
  flex-shrink: 0;
  display: flex;
  align-items: stretch;
  height: calc(50px + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--card);
  border-top: 1px solid var(--line);
  z-index: 20;
}
.main-tabbar .tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 0;
  background: none;
  padding: 6px 0 4px;
  font-size: 10px;
  color: var(--text-3);
  cursor: pointer;
  font-family: inherit;
}
.main-tabbar .tab-item .ico {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
}
.main-tabbar .tab-item.active { color: var(--primary); font-weight: 500; }
.main-tabbar .tab-item .ai-badge {
  position: relative;
}
.main-tabbar .tab-item .ai-badge::after {
  content: "AI";
  position: absolute;
  top: -4px;
  right: -10px;
  font-size: 8px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #7c5cff, #b06cff);
  padding: 1px 3px;
  border-radius: 4px;
  line-height: 1.1;
}

/* —— 工作台顶区 —— */
.wb-hero {
  background: linear-gradient(165deg, #4a9bff 0%, #3478f6 55%, #5eb0ff 100%);
  padding: 44px 16px 72px;
  color: #fff;
  position: relative;
}
.wb-hero-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.wb-hero-title { font-size: 22px; font-weight: 600; }
.wb-seg {
  display: flex;
  background: rgba(255, 255, 255, 0.22);
  border-radius: 16px;
  padding: 2px;
  font-size: 12px;
}
.wb-seg button {
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.85);
  padding: 4px 12px;
  border-radius: 14px;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
}
.wb-seg button.on {
  background: #fff;
  color: var(--primary);
  font-weight: 600;
}
.wb-kpi-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  text-align: center;
}
.wb-kpi-row .lbl { font-size: 12px; opacity: 0.92; margin-bottom: 4px; }
.wb-kpi-row .val { font-size: 20px; font-weight: 600; }
.wb-kpi-row .trend {
  font-size: 10px;
  opacity: 0.85;
  margin-top: 2px;
}
.wb-kpi-row .trend.down { color: #ffe7e7; }

.wb-perf-card {
  margin: -48px 12px 0;
  background: var(--card);
  border-radius: 12px;
  box-shadow: var(--shadow-card);
  padding: 14px 12px 12px;
  position: relative;
  z-index: 2;
}
.wb-perf-badge {
  position: absolute;
  top: 10px;
  right: 12px;
  font-size: 11px;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 2px 8px;
  border-radius: 10px;
}
.wb-perf-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  text-align: center;
  margin-top: 4px;
}
.wb-perf-grid .lbl { font-size: 11px; color: var(--text-3); }
.wb-perf-grid .val { font-size: 15px; font-weight: 600; color: var(--text); margin: 4px 0; }
.wb-perf-grid .trend { font-size: 10px; color: var(--text-3); }

.wb-section { padding: 16px 12px 0; }
.wb-section-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}
.wb-section-hd a {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-3);
  text-decoration: none;
}

/* 销售漏斗 */
.wb-funnel {
  display: flex;
  gap: 10px;
  align-items: stretch;
  background: var(--card);
  border-radius: 12px;
  padding: 12px;
  box-shadow: var(--shadow-card);
}
.wb-funnel-chart {
  width: 108px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.wb-funnel-chart .layer {
  width: 100%;
  text-align: center;
  font-size: 10px;
  color: #fff;
  padding: 6px 4px;
  clip-path: polygon(8% 0, 92% 0, 100% 100%, 0 100%);
}
.wb-funnel-chart .layer:nth-child(1) {
  width: 100%;
  background: #5b9cf8;
  clip-path: polygon(0 0, 100% 0, 88% 100%, 12% 100%);
  border-radius: 4px 4px 0 0;
  font-size: 11px;
  font-weight: 600;
  padding: 8px 4px;
}
.wb-funnel-chart .layer:nth-child(2) { width: 88%; background: #8b7cf6; }
.wb-funnel-chart .layer:nth-child(3) { width: 72%; background: #f5a962; }
.wb-funnel-chart .layer:nth-child(4) { width: 56%; background: #5ec9c9; border-radius: 0 0 4px 4px; }
.wb-funnel-list { flex: 1; min-width: 0; }
.wb-funnel-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  margin-bottom: 6px;
  border-radius: 8px;
  font-size: 13px;
  background: #f7f9fc;
}
.wb-funnel-row:last-child { margin-bottom: 0; }
.wb-funnel-row .dot {
  width: 4px;
  height: 14px;
  border-radius: 2px;
  margin-right: 8px;
}
.wb-funnel-row .name { flex: 1; display: flex; align-items: center; color: var(--text-2); }
.wb-funnel-row .num { font-weight: 600; color: var(--text); }

/* 快捷入口 */
.quick-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px 8px;
  padding: 4px 0 8px;
}
.quick-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-2);
  border: 0;
  background: none;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
}
.quick-tile .ico {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 20px;
  font-weight: 600;
}
.quick-tile.ico-orange .ico { background: linear-gradient(145deg, #ffb347, #ff8c42); }
.quick-tile.ico-blue .ico { background: linear-gradient(145deg, #5b9cf8, #3478f6); }
.quick-tile.ico-teal .ico { background: linear-gradient(145deg, #5ec9c9, #3db8b0); }
.quick-tile.ico-red .ico { background: linear-gradient(145deg, #ff7875, #ff4d4f); }
.quick-tile.ico-violet .ico { background: linear-gradient(145deg, #9f7aea, #7c5cff); }
.quick-tile.highlight .ico {
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--primary);
}

.wb-todo-empty {
  background: var(--card);
  border-radius: 12px;
  padding: 28px 16px;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
  box-shadow: var(--shadow-card);
}
.wb-todo-empty .illus {
  width: 120px;
  height: 80px;
  margin: 0 auto 12px;
  background: linear-gradient(180deg, #f0f4f8 0%, #e8eef5 100%);
  border-radius: 12px;
  opacity: 0.9;
}

/* —— 客户 Tab —— */
.cust-page { background: var(--bg-page); min-height: 100%; position: relative; }
.cust-hero {
  padding: 44px 16px 16px;
  background: linear-gradient(180deg, #e8f2ff 0%, var(--bg-page) 100%);
  position: relative;
}
.cust-hero-title { font-size: 22px; font-weight: 600; margin-bottom: 12px; }
.cust-mini-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.cust-mini-card {
  background: var(--card);
  border-radius: 10px;
  padding: 10px 8px;
  box-shadow: var(--shadow-card);
  font-size: 11px;
}
.cust-mini-card .ico-sm {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: #fff;
  margin-bottom: 6px;
}
.cust-mini-card .n { font-size: 16px; font-weight: 600; color: var(--text); }
.cust-mini-card .l { color: var(--text-3); margin-top: 2px; }

.cust-module {
  margin: 10px 12px 0;
  background: var(--card);
  border-radius: 12px;
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.cust-module-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  font-size: 15px;
  font-weight: 600;
}
.cust-module-hd .more { font-size: 13px; color: var(--text-3); font-weight: 400; }
.cust-module-inner {
  margin: 0 12px 12px;
  border-radius: 10px;
  padding: 12px;
  background: #f5f9ff;
}
.cust-module-inner.tone-orange { background: #fff8f0; }
.cust-module-inner.tone-teal { background: #f0faf9; }
.cust-stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  text-align: center;
  font-size: 11px;
  color: var(--text-3);
}
.cust-stat-row .v { font-size: 14px; font-weight: 600; color: var(--text); display: block; margin-top: 4px; }
.cust-module-ft {
  display: flex;
  gap: 16px;
  padding: 8px 14px 12px;
  font-size: 12px;
  color: var(--text-2);
}
.cust-fab {
  position: absolute;
  right: 20px;
  bottom: calc(70px + var(--safe-bottom));
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 0;
  background: var(--primary);
  color: #fff;
  font-size: 28px;
  line-height: 1;
  box-shadow: 0 4px 14px rgba(52, 120, 246, 0.45);
  cursor: pointer;
  z-index: 5;
}

/* —— 我的 —— */
.mine-page { background: var(--bg-page); min-height: 100%; padding-bottom: 16px; }
.mine-top {
  padding: 44px 16px 16px;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  font-size: 18px;
  color: var(--text-2);
}
.mine-top .badge-dot {
  position: relative;
}
.mine-top .badge-dot::after {
  content: "15";
  position: absolute;
  top: -6px;
  right: -10px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background: #ff4d4f;
  color: #fff;
  font-size: 10px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mine-profile {
  display: flex;
  gap: 14px;
  padding: 0 16px 16px;
  align-items: center;
}
.mine-profile .av {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 22px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.mine-profile .name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.mine-profile .name { font-size: 18px; font-weight: 600; }
.mine-profile .role {
  font-size: 11px;
  color: #fff;
  background: var(--primary);
  padding: 2px 8px;
  border-radius: 10px;
}
.mine-profile .meta {
  font-size: 13px;
  color: var(--text-2);
  margin-top: 6px;
  line-height: 1.5;
}
.mine-duo {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 0 12px;
  margin-bottom: 12px;
}
.mine-duo-card {
  background: var(--card);
  border-radius: 12px;
  padding: 14px;
  box-shadow: var(--shadow-card);
  position: relative;
  min-height: 88px;
}
.mine-duo-card .t { font-size: 15px; font-weight: 600; }
.mine-duo-card .s { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.mine-duo-card .bubble {
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 18px;
}
.mine-duo-card .bubble.blue { background: linear-gradient(145deg, #5b9cf8, #3478f6); }
.mine-duo-card .bubble.green { background: linear-gradient(145deg, #73d13d, #52c41a); }

.mine-list {
  margin: 0 12px;
  background: var(--card);
  border-radius: 12px;
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.mine-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  font-size: 15px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}
.mine-list-item:last-child { border-bottom: 0; }
.mine-list-item .chev { color: var(--text-3); }

/* —— 子页（营销工具包等） —— */
.app-sub-shell {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  background: var(--bg-page);
}
.app-sub-shell .scroll { padding-bottom: 88px; }

/* 工具包首页：2×2 工具卡 */
.tk-search {
  margin: 12px 12px 0;
  background: var(--card);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  color: var(--text-3);
  box-shadow: var(--shadow-card);
}
.tk-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 12px;
}
.tk-card {
  background: var(--card);
  border-radius: 12px;
  padding: 14px;
  box-shadow: var(--shadow-card);
  text-align: left;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  min-height: 108px;
}
.tk-card .tk-ico {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 10px;
}
.tk-card .tk-name { font-size: 15px; font-weight: 600; color: var(--text); }
.tk-card .tk-desc { font-size: 12px; color: var(--text-3); margin-top: 4px; line-height: 1.4; }
.tk-card.tone-blue .tk-ico { background: linear-gradient(145deg, #5b9cf8, #3478f6); }
.tk-card.tone-orange .tk-ico { background: linear-gradient(145deg, #ffb347, #ff8c42); }
.tk-card.tone-teal .tk-ico { background: linear-gradient(145deg, #5ec9c9, #3db8b0); }
.tk-card.tone-violet .tk-ico { background: linear-gradient(145deg, #9f7aea, #7c5cff); }
.tk-card.tone-gray .tk-ico { background: linear-gradient(145deg, #bfbfbf, #8c8c8c); }
.tk-card.disabled { opacity: 0.55; }

.tk-chips {
  display: flex;
  gap: 8px;
  padding: 10px 12px 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.tk-chips::-webkit-scrollbar { display: none; }
.tk-chip {
  flex: 0 0 auto;
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 13px;
  background: var(--card);
  color: var(--text-2);
  border: 1px solid var(--border);
}
.tk-chip.on {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: transparent;
  font-weight: 600;
}

.tk-list { margin: 10px 12px; background: var(--card); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow-card); }
.tk-list-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--border);
}
.tk-list-item:last-child { border-bottom: 0; }
.tk-list-item .title { font-size: 15px; font-weight: 500; color: var(--text); }
.tk-list-item .meta { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.tk-list-item .tag-mini {
  font-size: 11px;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 6px;
}

.tk-mat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 12px;
}
.tk-mat-card {
  background: var(--card);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
.tk-mat-card .cover {
  height: 96px;
  background: linear-gradient(135deg, #e8f2ff, #f0f4f8);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  font-size: 13px;
}
.tk-mat-card .bd { padding: 10px; }
.tk-mat-card .t { font-size: 13px; font-weight: 500; color: var(--text); }
.tk-mat-card .m { font-size: 11px; color: var(--text-3); margin-top: 4px; }

.tk-detail-body {
  margin: 10px 12px;
  background: var(--card);
  border-radius: 12px;
  padding: 14px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-2);
  box-shadow: var(--shadow-card);
  white-space: pre-wrap;
}
.tk-recent {
  padding: 0 12px 16px;
}
.tk-recent-hd {
  font-size: 14px;
  font-weight: 600;
  margin: 4px 0 8px;
  color: var(--text);
}

/* —— AI 助手 Tab（销售锦囊入口） —— */
.ai-hub-page {
  min-height: 100%;
  background: var(--bg-page);
  padding-bottom: 8px;
}
.ai-hub-page .ai-nav-title {
  font-size: 17px;
  font-weight: 600;
}
.ai-chat-card {
  margin: 8px 12px 0;
  background: var(--card);
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: var(--shadow-card);
}
.ai-chat-card .prompt {
  font-size: 14px;
  color: var(--text-3);
  padding: 10px 12px;
  background: #f5f7fa;
  border-radius: 8px;
  margin-bottom: 10px;
}
.ai-chat-card .chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.ai-chat-card .chip {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 14px;
  background: var(--primary-soft);
  color: var(--primary);
  border: 0;
  font-family: inherit;
}
.ai-tools-block {
  margin: 14px 12px 0;
  background: var(--card);
  border-radius: 12px;
  padding: 14px 12px 12px;
  box-shadow: var(--shadow-card);
}
.ai-tools-block .hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.ai-tools-block .hd .t {
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}
.ai-tools-block .hd .t .badge-ai {
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #7c5cff, #b06cff);
  padding: 2px 5px;
  border-radius: 4px;
}
.ai-tools-block .hd .more {
  font-size: 13px;
  color: var(--primary);
  border: 0;
  background: none;
  font-family: inherit;
  cursor: pointer;
}
.ai-tools-block .sub {
  font-size: 12px;
  color: var(--text-3);
  margin: -6px 0 10px;
  line-height: 1.45;
}
.ai-tools-mini {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.ai-tools-mini button {
  border: 0;
  background: #f5f9ff;
  border-radius: 10px;
  padding: 10px 4px 8px;
  font-size: 11px;
  color: var(--text-2);
  font-family: inherit;
  cursor: pointer;
}
.ai-tools-mini button .m-ico {
  display: block;
  width: 36px;
  height: 36px;
  margin: 0 auto 6px;
  border-radius: 10px;
  line-height: 36px;
  text-align: center;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
}
.ai-tools-mini button[data-tk="script"] .m-ico { background: linear-gradient(145deg, #5b9cf8, #3478f6); }
.ai-tools-mini button[data-tk="material"] .m-ico { background: linear-gradient(145deg, #ffb347, #ff8c42); }
.ai-tools-mini button[data-tk="sell"] .m-ico { background: linear-gradient(145deg, #5ec9c9, #3db8b0); }
.ai-tools-mini button[data-tk="case"] .m-ico { background: linear-gradient(145deg, #9f7aea, #7c5cff); }

.app-sub-shell .nav-btn.left[data-tk-back] { cursor: pointer; }
.tk-list-item[data-tk-nav],
.tk-mat-card[data-tk-nav] { cursor: pointer; }
.tk-list-item[data-tk-nav]:active,
.tk-mat-card[data-tk-nav]:active { opacity: 0.85; }
