/* ZITO.CRM shell — aligned with AI数字企业平台 (Knit Teal + Liquid Glass) */
:root {
  --primary: #0d4f4f;
  --primary-light: #1a6b6b;
  --primary-soft: #e6f2f2;
  --accent-gold: #c4a35a;
  --surface: #f2f2f7;
  --ink: #1d1d1f;
  --mute: #86868b;
  --crm-card: #ffffff;
  --crm-line: #E4E1D8;
  --font-scale: 1;
  --ios-grouped-bg: #eef1f0;
  --ios-secondary-grouped: #f2f2f7;
  --ios-separator: rgba(60, 60, 67, 0.12);
  --ios-label: #1d1d1f;
  --ios-secondary-label: #86868b;
  --ios-tertiary-label: #aeaeb2;
  --ios-fill-tertiary: rgba(118, 118, 128, 0.06);
  --ios-material-ultrathin: rgba(255, 255, 255, 0.55);
  --ios-material-regular: rgba(255, 255, 255, 0.78);
  --ios-material-thick: rgba(255, 255, 255, 0.88);
  --ios-material-chrome: rgba(255, 255, 255, 0.82);
  --ios-glass: var(--ios-material-regular);
  --ios-glass-elevated: var(--ios-material-thick);
  --ios-glass-border: rgba(255, 255, 255, 0.62);
  --ios-glass-edge: rgba(13, 79, 79, 0.06);
  --ios-glass-highlight: rgba(255, 255, 255, 0.72);
  --ios-glass-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.03), 0 1px 2px rgba(0, 0, 0, 0.03), 0 8px 32px rgba(13, 79, 79, 0.07);
  --ios-glass-shadow-float: 0 0 0 0.5px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.06), 0 24px 64px rgba(13, 79, 79, 0.1);
  --radius-apple: 22px;
  --radius-sm: 14px;
  --radius-xs: 10px;
  --shell-gap: 6px;
  --sidebar-width: 232px;
  --sidebar-collapsed: 64px;
  --content-max: 1080px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --touch-min: 44px;
  --mobile-gutter: 12px;
  --tablet-gutter: 16px;
  --desktop-gutter: 20px;
  --bp-tablet: 768px;
  --bp-desktop: 1024px;
  --duration-base: 240ms;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: light;
}

html {
  font-size: calc(15px * var(--font-scale, 1));
}
html, body, #root {
  margin: 0;
  padding: 0;
  height: 100%;
  max-height: 100dvh;
  overflow: hidden;
  background: var(--surface);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.47;
}
body, #root { font-size: inherit; }

body.app-body-locked {
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
}

#root {
  display: flex;
  flex-direction: column;
  min-height: 0;
  width: 100%;
}

* { box-sizing: border-box; }
button, input, select, textarea { font: inherit; }
button, [role="button"], .crm-nav-item, .crm-module-tab, .crm-os-kpi-tile,
.crm-module-tile, .crm-funnel-pill, .crm-hamburger, .crm-alert-row {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
button:active, .crm-nav-item:active, .crm-module-tab:active,
.crm-os-kpi-tile:active, .crm-module-tile:active {
  transition: transform 80ms var(--ease-out), opacity 80ms var(--ease-out);
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
::selection { background: color-mix(in srgb, var(--primary) 25%, transparent); }
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, 0.12); border-radius: 100px; }

.app-bg {
  position: fixed;
  inset: 0;
  z-index: -20;
  pointer-events: none;
  background:
    radial-gradient(60rem 40rem at -10% -20%, rgba(13, 79, 79, 0.09), transparent 60%),
    radial-gradient(50rem 36rem at 110% 0%, rgba(196, 163, 90, 0.07), transparent 55%),
    radial-gradient(42rem 32rem at 50% 120%, rgba(26, 107, 107, 0.06), transparent 60%);
}
.app-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(0, 0, 0, 0.028) 1px, transparent 1px);
  background-size: 3px 3px;
  opacity: 0.45;
}

.crm-app-shell {
  display: flex;
  align-items: stretch;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  max-height: 100dvh;
  min-height: 0;
  padding:
    max(var(--shell-gap), var(--safe-top))
    max(var(--shell-gap), var(--safe-right))
    max(var(--shell-gap), var(--safe-bottom))
    max(var(--shell-gap), var(--safe-left));
  gap: var(--shell-gap);
  position: relative;
  z-index: 1;
}

.liquid-glass {
  position: relative;
  background: var(--ios-glass);
  backdrop-filter: blur(48px) saturate(200%);
  -webkit-backdrop-filter: blur(48px) saturate(200%);
  border: 0.5px solid var(--ios-glass-border);
  box-shadow: var(--ios-glass-shadow);
}
.liquid-glass::before {
  content: "";
  pointer-events: none;
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(165deg, var(--ios-glass-highlight) 0%, transparent 38%, transparent 72%, var(--ios-glass-edge) 100%);
  opacity: 0.65;
}
.liquid-glass::after {
  content: "";
  pointer-events: none;
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0.5px 0 rgba(255, 255, 255, 0.5);
  opacity: 0.4;
}
.liquid-glass > * { position: relative; z-index: 1; }

.crm-sidebar-float {
  flex: 0 0 auto;
  width: var(--sidebar-width);
  height: 100%;
  max-height: 100%;
  border-radius: var(--radius-apple);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--ios-glass-shadow-float);
  border: 0.5px solid var(--ios-glass-border);
  background: var(--ios-material-thick);
  backdrop-filter: blur(56px) saturate(210%);
  -webkit-backdrop-filter: blur(56px) saturate(210%);
  transition: width var(--duration-base) var(--ease-out);
  color: var(--ios-label);
}
.crm-sidebar-float.collapsed { width: var(--sidebar-collapsed); }
.crm-sidebar-float .crm-nav-label { display: block; }
.crm-sidebar-float.collapsed .crm-nav-label,
.crm-sidebar-float.collapsed .crm-nav-group-title,
.crm-sidebar-float.collapsed .crm-brand-text,
.crm-sidebar-float.collapsed .crm-side-footer-text { display: none !important; }
.crm-sidebar-float.collapsed .crm-nav-item {
  justify-content: center;
  padding-left: 10px;
  padding-right: 10px;
}
.crm-sidebar-float.collapsed .crm-nav-item .crm-nav-active-bar { display: none; }

.crm-main-pane {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-apple);
  overflow: hidden;
  border: 0.5px solid var(--ios-glass-border);
  box-shadow: var(--ios-glass-shadow);
  background: color-mix(in srgb, var(--ios-material-ultrathin) 92%, var(--ios-secondary-grouped));
}

.crm-sync-warn {
  margin: 8px 16px 0;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 12.5px;
  font-weight: 600;
  color: #92400e;
  background: rgba(251, 191, 36, 0.18);
  border: 0.5px solid rgba(245, 158, 11, 0.35);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}

.crm-topbar {
  flex: 0 0 auto;
  height: 3rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  gap: 12px;
  border-bottom: 0.5px solid var(--ios-separator);
  background: var(--ios-material-chrome);
  backdrop-filter: blur(56px) saturate(210%);
  -webkit-backdrop-filter: blur(56px) saturate(210%);
}

.crm-content {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: auto;
  position: relative;
  padding: 0;
}

.crm-content-inner {
  position: relative;
  max-width: var(--content-max);
  margin: 0 auto;
  width: 100%;
  min-height: 100%;
  padding: 10px 12px calc(20px + var(--safe-bottom));
  overflow-x: hidden;
  color: var(--ios-label);
}

.crm-content-aura {
  pointer-events: none;
  position: absolute;
  inset: 0 0 auto 0;
  height: 12rem;
  z-index: 0;
  background:
    radial-gradient(42rem 22rem at 30% -10%, color-mix(in srgb, var(--primary) 10%, transparent), transparent 70%),
    linear-gradient(to bottom, color-mix(in srgb, var(--primary) 4%, transparent), transparent);
}

.crm-content-inner > *:not(.crm-content-aura) {
  position: relative;
  z-index: 1;
}

@media (min-width: 640px) {
  .crm-content-inner { padding: 12px 16px calc(24px + var(--safe-bottom)); }
}

@media (min-width: 1024px) {
  .crm-content-inner { padding: 14px 20px calc(28px + var(--safe-bottom)); }
}

.crm-nav-group-title {
  padding: 14px 16px 6px;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ios-tertiary-label);
  font-weight: 700;
}
.crm-nav-group + .crm-nav-group {
  margin-top: 4px;
  border-top: 0.5px solid var(--ios-separator);
  padding-top: 2px;
}
.crm-nav-group-hint {
  display: block;
  margin-top: 2px;
  font-size: 9px;
  letter-spacing: 0.02em;
  text-transform: none;
  font-weight: 500;
  color: var(--ios-tertiary-label);
  opacity: 0.85;
}

.crm-nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 8px 10px;
  margin: 2px 8px;
  border-radius: 12px;
  font-size: 13px;
  cursor: pointer;
  color: var(--ios-secondary-label);
  font-weight: 500;
  transition: background-color var(--duration-base) var(--ease-out), color var(--duration-base) var(--ease-out);
}
.crm-nav-item:hover {
  background: var(--ios-fill-tertiary);
  color: var(--ios-label);
}
.crm-nav-item.active {
  background: color-mix(in srgb, var(--primary) 9%, white);
  color: var(--primary);
  font-weight: 650;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 16%, transparent);
}
.crm-nav-item .crm-nav-active-bar {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  border-radius: 99px;
  background: var(--primary);
}
.crm-nav-icon {
  display: inline-flex;
  width: 30px;
  height: 30px;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  flex-shrink: 0;
  color: var(--ios-tertiary-label);
  background: var(--ios-fill-tertiary, rgba(118, 118, 128, 0.08));
  transition: background-color 0.18s ease, color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}
.crm-nav-item:hover .crm-nav-icon {
  background: color-mix(in srgb, var(--primary) 8%, white);
  color: var(--ios-label);
}
.crm-nav-item.active .crm-nav-icon {
  background: color-mix(in srgb, var(--primary) 16%, white);
  color: var(--primary);
  transform: translateY(-0.5px);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 18%, transparent);
}
.crm-page-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.crm-page-title-icon {
  display: inline-flex;
  width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
  border-radius: 11px;
  flex-shrink: 0;
  background: color-mix(in srgb, var(--primary) 12%, white);
  color: var(--primary);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 14%, transparent);
}
.crm-page-title-icon svg,
.crm-btn-icon,
.crm-module-icon-well svg {
  stroke-width: var(--crm-icon-stroke, 1.75);
}
.crm-module-icon-well {
  transition: transform 0.15s ease, background-color 0.15s ease;
}
.crm-dash-modules .crm-card:hover .crm-module-icon-well {
  transform: scale(1.04);
}

.crm-card-ios {
  background: rgba(255, 255, 255, 0.78);
  border: 0.5px solid var(--ios-separator);
  border-radius: var(--radius-apple);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
}

.crm-hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  min-width: var(--touch-min);
  min-height: var(--touch-min);
  padding: 0;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  border-radius: var(--radius-xs);
  transition: background var(--duration-base) var(--ease-out), transform 80ms var(--ease-out);
}
.crm-hamburger--topbar {
  background: color-mix(in srgb, var(--primary) 8%, white);
  color: var(--primary);
}
.crm-hamburger--close {
  background: transparent;
  color: var(--ios-label);
}
.crm-backdrop { display: none; }
.crm-page-header-main {
  flex: 1 1 auto;
  min-width: 0;
}

@media (max-width: 767px) {
  .crm-hamburger { display: inline-flex !important; }
  .crm-sidebar-float {
    position: fixed !important;
    z-index: 250;
    top: max(var(--shell-gap), var(--safe-top));
    bottom: max(var(--shell-gap), var(--safe-bottom));
    left: max(var(--shell-gap), var(--safe-left));
    height: auto !important;
    max-height: none;
    width: min(88vw, 320px) !important;
    border-radius: var(--radius-apple);
    transition: transform 0.22s var(--ease-out);
    box-shadow: var(--ios-glass-shadow-float);
  }
  .crm-sidebar-float.closed { transform: translateX(calc(-100% - 20px)); pointer-events: none; }
  .crm-sidebar-float.open { transform: translateX(0); pointer-events: auto; }
  .crm-sidebar-float.collapsed { width: min(88vw, 320px) !important; }
  .crm-sidebar-float .crm-nav-item {
    min-height: var(--touch-min);
    padding: 10px 12px;
  }
  .crm-backdrop.show {
    display: block !important;
    position: fixed;
    inset: 0;
    background: rgba(29, 29, 31, 0.42);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 240;
    touch-action: none;
  }
  body.crm-nav-open { overflow: hidden; }
  body.crm-nav-open .crm-content { overflow: hidden !important; }
  .crm-role-select { display: none !important; }
  .crm-user-avatar { display: flex !important; }
  .crm-settings-grid, .crm-two-col { grid-template-columns: 1fr !important; }
  .crm-app-shell {
    padding:
      max(4px, var(--safe-top))
      max(4px, var(--safe-right))
      max(4px, var(--safe-bottom))
      max(4px, var(--safe-left));
    gap: 4px;
  }
  .crm-main-pane { border-radius: var(--radius-sm); }
  .crm-content-inner {
    padding: 8px var(--mobile-gutter) calc(16px + var(--safe-bottom));
  }
  .crm-page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 2px 0;
  }
  .crm-page-toolbar {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .crm-page-search {
    width: 100%;
    min-width: 0;
    order: -1;
  }
  .crm-page-search-input {
    min-width: 0;
    height: var(--touch-min);
    font-size: 16px;
  }
  .crm-page-title { font-size: 1.28rem; }
  .crm-page-sub { font-size: 12.5px; max-width: none; }
  .crm-module-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    padding-bottom: 4px;
    margin-left: -4px;
    margin-right: -4px;
    padding-left: 4px;
    padding-right: 4px;
    scrollbar-width: none;
  }
  .crm-module-tabs::-webkit-scrollbar { display: none; }
  .crm-module-tab {
    flex: 0 0 auto;
    scroll-snap-align: start;
    min-height: var(--touch-min);
    padding: 10px 14px;
    white-space: nowrap;
  }
  .crm-record-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .crm-os-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .crm-os-kpi-tile {
    min-height: 72px;
    padding: 10px 12px;
  }
  .crm-os-grid { grid-template-columns: 1fr; }
  .crm-os-list-row {
    min-height: var(--touch-min);
    padding: 12px 14px;
  }
  .crm-os-list-actions {
    flex-wrap: wrap;
    gap: 8px;
  }
  .crm-os-list-actions button { min-height: 36px; }
  .crm-stat-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 10px 12px;
  }
  .crm-stat-tile { padding: 10px 12px; }
  .crm-stat-tile-value { font-size: 1.05rem; }
  .crm-analytics-head { padding: 14px 12px 10px; }
  .crm-analytics-charts { padding: 0 12px 12px; }
  .crm-conversion-strip {
    overflow-x: auto;
    flex-wrap: nowrap;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    padding-bottom: 6px;
    scrollbar-width: none;
  }
  .crm-conversion-strip::-webkit-scrollbar { display: none; }
  .crm-conversion-node { scroll-snap-align: start; flex-shrink: 0; }
  .crm-funnel-pill { min-width: calc(50% - 4px); flex: 1 1 calc(50% - 4px); }
  .crm-module-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .crm-module-tile { min-height: 88px; padding: 12px; }
  .crm-kpi-row { grid-template-columns: 1fr; }
  .crm-pipeline-row { grid-template-columns: 1fr; gap: 6px; padding: 14px 12px; }
  .crm-pipeline-col--end { grid-column: 1; text-align: left; }
  .crm-dash-hero { padding: 14px 14px; }
  .crm-dash-hero-top { flex-direction: column; gap: 8px; }
  .crm-dash-hero-stats { flex-direction: column; }
  .crm-dash-stat { flex: 1 1 auto; width: 100%; }
  .crm-dash-alert-banner {
    flex-wrap: wrap;
    gap: 10px;
  }
  .crm-dash-alert-link {
    margin-left: 0;
    min-height: var(--touch-min);
    display: inline-flex;
    align-items: center;
  }
  .crm-table-scroll,
  .crm-content-inner div:has(> table),
  .crm-analytics-panel div:has(> table) {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    max-width: 100%;
  }
  .crm-content-inner table { min-width: 640px; }
  .crm-chart-card .recharts-responsive-container { min-height: 200px; }
  .crm-topbar {
    height: auto;
    min-height: var(--touch-min);
    flex-wrap: wrap;
    padding: 8px 10px;
    gap: 8px;
  }
  .crm-search-wrap {
    order: 3;
    flex-basis: 100%;
    max-width: none !important;
  }
  .crm-hero-stats { flex-direction: column !important; align-items: flex-start !important; }
  input[type="text"], input[type="number"], input[type="email"],
  input[type="password"], input[type="date"], input[type="search"],
  select, textarea {
    min-height: var(--touch-min);
    font-size: 16px;
  }
}

@media (min-width: 768px) {
  .crm-sidebar-float.closed { transform: none !important; pointer-events: auto !important; }
  .crm-hamburger { display: none !important; }
}

/* ── 平板深度布局 (768–1023) ── */
@media (min-width: 768px) and (max-width: 1023px) {
  .crm-app-shell {
    padding:
      max(6px, var(--safe-top))
      max(6px, var(--safe-right))
      max(6px, var(--safe-bottom))
      max(6px, var(--safe-left));
    gap: 6px;
  }
  .crm-sidebar-float {
    width: var(--sidebar-collapsed) !important;
  }
  .crm-sidebar-float .crm-nav-label,
  .crm-sidebar-float .crm-nav-group-title,
  .crm-sidebar-float .crm-brand-text,
  .crm-sidebar-float .crm-side-footer-text {
    display: none !important;
  }
  .crm-sidebar-float .crm-nav-item {
    justify-content: center;
    padding: 10px;
    min-height: var(--touch-min);
    margin: 2px 6px;
  }
  .crm-sidebar-float .crm-nav-item .crm-nav-active-bar { display: none; }
  .crm-sidebar-float .crm-nav-icon {
    width: 32px;
    height: 32px;
  }
  .crm-content-inner {
    padding: 12px var(--tablet-gutter) calc(20px + var(--safe-bottom));
  }
  .crm-page-header {
    align-items: center;
    gap: 12px;
  }
  .crm-page-toolbar {
    flex-shrink: 0;
  }
  .crm-kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .crm-os-kpi-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .crm-os-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .crm-record-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .crm-stat-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .crm-module-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .crm-bento { grid-template-columns: 1fr 1fr; }
  .crm-bento-wide { grid-column: span 2; }
  .crm-analytics-charts { grid-template-columns: 1fr 1fr; }
  .crm-dash-hero-body { grid-template-columns: 1fr 1fr; }
  .crm-pipeline-row {
    grid-template-columns: 1.2fr 1fr 80px 1fr;
    gap: 10px;
  }
  .crm-pipeline-col--end { grid-column: auto; text-align: right; }
  .crm-module-tabs { gap: 6px; }
  .crm-module-tab { min-height: 40px; }
  .crm-funnel-pills { gap: 6px; }
  .crm-funnel-pill { min-width: 96px; }
}

@media (max-width: 900px) {
  .crm-settings-grid, .crm-two-col { grid-template-columns: 1fr !important; }
  .crm-analytics-charts { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .crm-topbar { height: auto; min-height: 52px; flex-wrap: wrap; padding: 8px 10px; }
  .crm-search-wrap { order: 3; flex-basis: 100%; max-width: none !important; }
  .crm-hero-stats { flex-direction: column !important; align-items: flex-start !important; }
}

/* 横屏手机：略增列数，避免 KPI 过高 */
@media (max-width: 767px) and (orientation: landscape) {
  .crm-os-kpi-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .crm-stat-row { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .crm-module-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ── Page header (Shell) ── */
.crm-page {
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: crm-fade-in 0.35s var(--ease-out) both;
}
.crm-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 4px 2px 2px;
}
.crm-page-eyebrow {
  margin: 0 0 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--primary);
  opacity: 0.85;
}
.crm-page-title {
  margin: 0;
  font-size: clamp(1.35rem, 2.2vw, 1.65rem);
  font-weight: 750;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1.15;
}
.crm-page-sub {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--mute);
  max-width: 42rem;
  line-height: 1.45;
}
.crm-page-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.crm-page-search {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 180px;
}
.crm-page-search-icon {
  position: absolute;
  left: 11px;
  color: var(--ios-tertiary-label);
  pointer-events: none;
}
.crm-page-search-input {
  width: 100%;
  min-width: 180px;
  height: 34px;
  padding: 0 12px 0 32px;
  border: 0.5px solid var(--ios-separator);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  font-size: 13px;
  outline: none;
  transition: border-color var(--duration-base) var(--ease-out), box-shadow var(--duration-base) var(--ease-out);
}
.crm-page-search-input:focus {
  border-color: color-mix(in srgb, var(--primary) 35%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 12%, transparent);
}

/* ── Dashboard ── */
.crm-dash {
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: crm-fade-in 0.4s var(--ease-out) both;
}
@keyframes crm-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.crm-funnel-strip {
  padding: 12px 14px;
  border-radius: var(--radius-apple);
  background: var(--ios-material-regular);
  border: 0.5px solid var(--ios-separator);
  box-shadow: var(--ios-glass-shadow);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
}
.crm-funnel-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: 650;
  color: var(--ink);
}
.crm-funnel-head svg { color: var(--primary); flex-shrink: 0; }
.crm-funnel-head-sub {
  margin-left: auto;
  font-size: 11px;
  font-weight: 500;
  color: var(--mute);
}
.crm-funnel-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.crm-funnel-pill {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 88px;
  padding: 8px 12px;
  border: 0.5px solid var(--ios-separator);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.65);
  cursor: pointer;
  transition: transform var(--duration-base) var(--ease-out), box-shadow var(--duration-base) var(--ease-out), border-color var(--duration-base) var(--ease-out);
}
.crm-funnel-pill:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--primary) 22%, transparent);
  box-shadow: 0 4px 14px rgba(13, 79, 79, 0.08);
}
.crm-funnel-pill-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--mute);
  letter-spacing: 0.02em;
}
.crm-funnel-pill-val {
  font-size: 15px;
  font-weight: 800;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
}

.crm-dash-hero {
  position: relative;
  overflow: hidden;
  padding: 18px 20px;
  border-radius: var(--radius-apple);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.92) 0%, rgba(255, 255, 255, 0.72) 100%);
  border: 0.5px solid var(--ios-separator);
  box-shadow: var(--ios-glass-shadow);
  backdrop-filter: blur(32px) saturate(190%);
  -webkit-backdrop-filter: blur(32px) saturate(190%);
}
.crm-dash-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(28rem 14rem at 0% 0%, color-mix(in srgb, var(--primary) 12%, transparent), transparent 60%),
    radial-gradient(22rem 12rem at 100% 100%, color-mix(in srgb, var(--accent-gold) 10%, transparent), transparent 55%);
  opacity: 0.9;
}
.crm-dash-hero > * { position: relative; z-index: 1; }
.crm-dash-hero-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.crm-dash-hero-eyebrow {
  margin: 0 0 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--primary);
}
.crm-dash-hero-date {
  margin: 0;
  font-size: 13px;
  color: var(--mute);
}
.crm-dash-hero-body {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(140px, 0.9fr);
  gap: 16px;
  align-items: stretch;
}
.crm-dash-hero-main { min-width: 0; }
.crm-dash-hero-label {
  margin: 0 0 6px;
  font-size: 12px;
  color: var(--mute);
  font-weight: 600;
}
.crm-dash-hero-value {
  margin: 0;
  font-size: clamp(1.75rem, 3.5vw, 2.35rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
}
.crm-dash-hero-trend {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 8px 0 0;
  font-size: 12px;
  font-weight: 650;
}
.crm-dash-hero-trend.up { color: #1a6b6b; }
.crm-dash-hero-trend.down { color: #A93A1E; }
.crm-dash-hero-spark {
  min-height: 88px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--primary) 4%, white);
  border: 0.5px solid color-mix(in srgb, var(--primary) 8%, transparent);
  padding: 6px 4px 0;
}
.crm-dash-hero-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  grid-column: 1 / -1;
  margin-top: 4px;
}
.crm-dash-stat {
  flex: 1 1 120px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.55);
  border: 0.5px solid var(--ios-separator);
}
.crm-dash-stat-label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  color: var(--mute);
  margin-bottom: 4px;
}
.crm-dash-stat-val {
  display: block;
  font-size: 16px;
  font-weight: 800;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
}
.crm-dash-alert-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  grid-column: 1 / -1;
  margin-top: 2px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--accent-gold) 12%, white);
  border: 0.5px solid color-mix(in srgb, var(--accent-gold) 28%, transparent);
  font-size: 12.5px;
  color: var(--ink);
}
.crm-dash-alert-banner svg { color: var(--accent-gold); flex-shrink: 0; }
.crm-dash-alert-link {
  margin-left: auto;
  border: none;
  background: transparent;
  color: var(--primary);
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
  padding: 0;
}
.crm-dash-alert-link:hover { text-decoration: underline; }

.crm-module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 10px;
}
.crm-module-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 12px 12px 12px 12px;
  border: 0.5px solid var(--ios-separator);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.72);
  cursor: pointer;
  text-align: left;
  transition: transform var(--duration-base) var(--ease-out), box-shadow var(--duration-base) var(--ease-out);
}
.crm-module-tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(13, 79, 79, 0.08);
}
.crm-module-icon {
  display: inline-flex;
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  margin-bottom: 2px;
}
.crm-module-num {
  font-size: 20px;
  font-weight: 800;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.crm-module-label {
  font-size: 12px;
  font-weight: 650;
  color: var(--ink);
}
.crm-module-extra {
  font-size: 10px;
  font-weight: 600;
}
.crm-module-arrow {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ios-tertiary-label);
  opacity: 0.6;
}

.crm-kpi-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.crm-kpi-tile {
  padding: 14px 14px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.78);
  border: 0.5px solid var(--ios-separator);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
  border-top: 3px solid var(--kpi-accent, var(--primary));
}
.crm-kpi-tile-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.crm-kpi-tile-label {
  font-size: 11px;
  font-weight: 650;
  color: var(--mute);
}
.crm-kpi-tile-value {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.crm-kpi-tile-sub {
  margin-top: 4px;
  font-size: 11px;
  color: var(--mute);
}

.crm-bento {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.crm-bento-wide { grid-column: span 2; }
.crm-bento-full { grid-column: 1 / -1; }

.crm-chart-card,
.crm-panel {
  padding: 0;
  overflow: hidden;
}
.crm-chart-card .crm-chart-head,
.crm-panel .crm-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px 10px;
  border-bottom: 0.5px solid var(--ios-separator);
}
.crm-chart-head h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 750;
  color: var(--ink);
}
.crm-chart-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--primary);
  padding: 3px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--primary) 10%, white);
}
.crm-chart-card .recharts-responsive-container {
  padding: 4px 8px 12px;
}

.crm-panel-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 750;
  color: var(--ink);
}

.crm-alert-list { padding: 4px 0; }
.crm-alert-row {
  display: grid;
  grid-template-columns: 8px auto 1fr auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 10px 16px;
  border: none;
  border-bottom: 0.5px solid var(--ios-separator);
  background: transparent;
  cursor: pointer;
  text-align: left;
  font-size: 12.5px;
  transition: background var(--duration-base) var(--ease-out);
}
.crm-alert-row:hover { background: var(--ios-fill-tertiary); }
.crm-alert-row:last-child { border-bottom: none; }
.crm-alert-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.crm-alert-dot.lv-high { background: #A93A1E; box-shadow: 0 0 0 3px rgba(169, 58, 30, 0.15); }
.crm-alert-dot.lv-mid { background: var(--accent-gold); box-shadow: 0 0 0 3px rgba(196, 163, 90, 0.18); }
.crm-alert-dot.lv-low { background: var(--primary-light); box-shadow: 0 0 0 3px rgba(26, 107, 107, 0.12); }
.crm-alert-type {
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
}
.crm-alert-text {
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crm-team-list { padding: 6px 0 10px; }
.crm-team-row {
  padding: 12px 16px;
  border-bottom: 0.5px solid var(--ios-separator);
}
.crm-team-row:last-child { border-bottom: none; }
.crm-team-row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.crm-team-identity {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.crm-team-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 12%, white);
  flex-shrink: 0;
}
.crm-team-avatar.top {
  background: color-mix(in srgb, var(--accent-gold) 18%, white);
  color: #7a6228;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent-gold) 35%, transparent);
}
.crm-team-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}
.crm-team-amount {
  font-size: 13px;
  font-weight: 800;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.crm-team-bar {
  height: 6px;
  border-radius: 99px;
  background: var(--ios-fill-tertiary);
  overflow: hidden;
  margin-bottom: 8px;
}
.crm-team-bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  transition: width 0.6s var(--ease-out);
}
.crm-team-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
}
.crm-team-metric { min-width: 44px; }
.crm-team-metric-val {
  display: block;
  font-size: 12px;
  font-weight: 800;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.crm-team-metric-label {
  display: block;
  font-size: 10px;
  color: var(--mute);
  margin-top: 1px;
}

.crm-pipeline-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr 100px 1fr 110px;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 0.5px solid var(--ios-separator);
  cursor: pointer;
  font-size: 13px;
  transition: background var(--duration-base) var(--ease-out);
}
.crm-pipeline-row:hover { background: var(--ios-fill-tertiary); }
.crm-pipeline-row:last-child { border-bottom: none; }
.crm-pipeline-po {
  font-weight: 750;
  color: var(--ink);
}
.crm-pipeline-style {
  font-size: 12px;
  color: var(--mute);
  margin-top: 2px;
}
.crm-pipeline-customer { color: var(--mute); }
.crm-pipeline-bar {
  height: 5px;
  border-radius: 99px;
  background: var(--ios-fill-tertiary);
  overflow: hidden;
}
.crm-pipeline-bar-fill {
  height: 100%;
  border-radius: inherit;
  transition: width 0.5s var(--ease-out);
}
.crm-pipeline-pct {
  font-size: 11px;
  color: var(--mute);
  margin-top: 3px;
}
.crm-pipeline-col--end { text-align: right; font-variant-numeric: tabular-nums; }
.crm-pipeline-amount { font-weight: 750; color: var(--ink); }
.crm-pipeline-ship { font-size: 11px; color: var(--mute); margin-top: 2px; }
.crm-pipeline-ship.urgent { color: #A93A1E; font-weight: 650; }

.crm-empty-state {
  padding: 20px 16px;
  text-align: center;
  font-size: 12.5px;
  color: var(--mute);
}

/* ── 跟单 OS 工作台 ── */
.crm-os-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 10px;
  margin-bottom: 4px;
}
.crm-os-kpi-tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding: 12px 14px;
  border: 0.5px solid var(--ios-separator);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.78);
  border-top: 3px solid var(--kpi-accent, var(--primary));
  cursor: pointer;
  text-align: left;
  transition: transform var(--duration-base) var(--ease-out), box-shadow var(--duration-base) var(--ease-out);
}
.crm-os-kpi-tile:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(13, 79, 79, 0.07);
}
.crm-os-kpi-label {
  font-size: 10px;
  font-weight: 650;
  color: var(--mute);
}
.crm-os-kpi-num {
  font-size: 22px;
  font-weight: 800;
  color: var(--kpi-accent, var(--primary));
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.crm-os-kpi-sub {
  font-size: 10px;
  color: var(--mute);
}
.crm-os-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}
.crm-os-list-card { padding: 0; overflow: hidden; }
.crm-os-list-head { padding-bottom: 8px !important; }
.crm-os-list-body { padding: 0; }
.crm-os-list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 0.5px solid var(--ios-separator);
  font-size: 12.5px;
  color: var(--ink);
}
.crm-os-list-row:last-child { border-bottom: none; }
.crm-os-list-row--stack {
  flex-direction: column;
  align-items: stretch;
}
.crm-os-list-row--split {
  display: flex;
  justify-content: space-between;
}
.crm-os-list-row-title {
  font-weight: 650;
  color: var(--ink);
}
.crm-os-list-row-meta {
  font-size: 11px;
  color: var(--mute);
  margin-top: 2px;
}
.crm-os-list-row-warn {
  font-size: 11px;
  color: #A93A1E;
  font-weight: 650;
}
.crm-os-list-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}
.crm-os-footnote {
  margin-top: 4px;
  padding: 14px 16px !important;
  font-size: 12.5px;
  color: var(--mute);
  background: color-mix(in srgb, var(--primary) 4%, white) !important;
}

@media (max-width: 1024px) {
  .crm-kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .crm-bento { grid-template-columns: 1fr; }
  .crm-bento-wide, .crm-bento-full { grid-column: 1; }
  .crm-dash-hero-body { grid-template-columns: 1fr; }
  .crm-pipeline-row {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .crm-pipeline-col--end { grid-column: 1 / -1; text-align: left; }
}

@media (max-width: 640px) {
  .crm-kpi-row { grid-template-columns: 1fr; }
  .crm-funnel-pill { min-width: calc(50% - 4px); flex: 1 1 calc(50% - 4px); }
  .crm-module-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .crm-page-header { flex-direction: column; }
  .crm-page-search { width: 100%; }
  .crm-pipeline-row { grid-template-columns: 1fr; }
  .crm-stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .crm-conversion-strip { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; }
}

/* ── 统一统计分析组件 ── */
.crm-analytics-panel {
  padding: 0 !important;
  overflow: hidden;
  margin-bottom: 14px;
}
.crm-analytics-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 16px 16px 12px;
  border-bottom: 0.5px solid var(--ios-separator);
}
.crm-analytics-title {
  margin: 0;
  font-size: 14px;
  font-weight: 750;
  color: var(--ink);
}
.crm-analytics-sub {
  margin: 4px 0 0;
  font-size: 11.5px;
  color: var(--mute);
  line-height: 1.4;
}
.crm-stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 10px;
  padding: 12px 16px;
}
.crm-stat-tile {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.72);
  border: 0.5px solid var(--ios-separator);
  border-top: 3px solid var(--stat-accent, var(--primary));
}
.crm-stat-tile-label {
  display: block;
  font-size: 10px;
  font-weight: 650;
  color: var(--mute);
  letter-spacing: 0.02em;
}
.crm-stat-tile-value {
  display: block;
  margin-top: 5px;
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.crm-stat-tile-sub {
  display: block;
  margin-top: 4px;
  font-size: 10px;
  color: var(--mute);
}
.crm-analytics-charts {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 12px;
  padding: 0 16px 16px;
}
.crm-analytics-rank {
  grid-column: 1 / -1;
  padding: 0 16px 16px;
}
.crm-rank-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 0.5px solid var(--ios-separator);
  font-size: 12.5px;
}
.crm-rank-row:last-child { border-bottom: none; }
.crm-rank-name { font-weight: 650; color: var(--ink); }
.crm-rank-meta { font-size: 11px; color: var(--mute); font-variant-numeric: tabular-nums; }

.crm-conversion-strip {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 4px;
  padding: 12px 16px;
  border-bottom: 0.5px solid var(--ios-separator);
  background: color-mix(in srgb, var(--primary) 3%, white);
}
.crm-conversion-node {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  min-width: 72px;
  padding: 6px 10px;
  border-radius: var(--radius-xs);
  background: rgba(255, 255, 255, 0.75);
  border: 0.5px solid var(--ios-separator);
}
.crm-conversion-val {
  font-size: 15px;
  font-weight: 800;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
}
.crm-conversion-label {
  font-size: 10px;
  font-weight: 650;
  color: var(--mute);
  margin-top: 2px;
}
.crm-conversion-sub {
  font-size: 9px;
  color: var(--ios-tertiary-label);
  margin-top: 1px;
}
.crm-conversion-arrow {
  color: var(--ios-tertiary-label);
  font-size: 12px;
  font-weight: 700;
  padding: 0 2px;
}

.crm-module-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.crm-module-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 0.5px solid var(--ios-separator);
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
  transition: all var(--duration-base) var(--ease-out);
}
.crm-module-tab:hover {
  border-color: color-mix(in srgb, var(--primary) 20%, transparent);
}
.crm-module-tab.active {
  background: var(--tab-accent, var(--primary));
  color: #fff;
  border-color: transparent;
  font-weight: 750;
  box-shadow: 0 4px 14px rgba(13, 79, 79, 0.18);
}
.crm-module-tab-count {
  opacity: 0.85;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.crm-year-bars {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 8px 4px 4px;
}
.crm-year-row-head {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  margin-bottom: 4px;
  font-weight: 650;
}
.crm-year-bar {
  height: 6px;
  border-radius: 99px;
  background: var(--ios-fill-tertiary);
  overflow: hidden;
}
.crm-year-bar-fill {
  height: 100%;
  border-radius: inherit;
  transition: width 0.5s var(--ease-out);
}

.crm-record-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 14px;
  margin-top: 4px;
}

.crm-prod-backlog {
  max-height: 280px;
  overflow-y: auto;
  padding: 4px 8px 8px;
}
.crm-prod-backlog > div {
  border-bottom: 0.5px solid var(--ios-separator);
}
.crm-prod-backlog > div:last-child { border-bottom: none; }
.crm-chart-badge--warn {
  color: #A93A1E;
  background: color-mix(in srgb, #A93A1E 10%, white);
}

@media (max-width: 900px) {
  .crm-analytics-charts { grid-template-columns: 1fr; }
  .crm-stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ── 按钮触控 (UI/UX Pro Max: 44px touch target) ── */
.crm-btn {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
@media (max-width: 767px) {
  .crm-btn:not(.crm-btn--sm) {
    min-height: var(--touch-min);
    padding-top: 10px;
    padding-bottom: 10px;
  }
  .crm-btn--sm {
    min-height: 36px;
    padding-top: 8px;
    padding-bottom: 8px;
  }
}

/* ── iOS 27 内容栏：居中收窄，避免超宽屏横向拉满 ── */
@media (min-width: 1280px) {
  :root { --content-max: 1080px; }
}
@media (min-width: 1680px) {
  :root { --content-max: 1120px; }
}
.crm-content-inner {
  max-width: min(var(--content-max), 100%);
}
.crm-card {
  border-radius: var(--radius-sm) !important;
  border-color: var(--ios-separator) !important;
  box-shadow: var(--ios-glass-shadow) !important;
  background: var(--ios-material-thick) !important;
}
.crm-intel-item {
  border-radius: var(--radius-xs) !important;
  background: var(--ios-material-thick) !important;
  border: 0.5px solid var(--ios-separator) !important;
}
.crm-page-head h2 {
  font-size: 1.5rem !important;
  font-weight: 700 !important;
  letter-spacing: -0.03em;
}
.crm-topbar .crm-search-wrap input {
  min-height: 36px;
  border-radius: 10px !important;
  background: var(--ios-fill-tertiary) !important;
  border: 0.5px solid var(--ios-separator) !important;
  box-shadow: none !important;
}
.crm-topbar .crm-role-select {
  min-height: 36px;
  border-radius: 10px;
  background: var(--ios-fill-tertiary);
  border: 0.5px solid var(--ios-separator);
}
.crm-topbar .crm-user-avatar,
.crm-topbar [title] {
  min-width: 36px;
  min-height: 36px;
}
.crm-page-actions button {
  min-height: 36px;
}
.crm-density-compact .crm-content-inner {
  padding-top: 8px;
  padding-bottom: 16px;
}
.crm-density-compact .crm-card,
.crm-density-compact .crm-card-ios {
  border-radius: 12px !important;
}
.crm-density-spacious .crm-content-inner {
  padding-top: 22px;
  padding-bottom: 28px;
}
.crm-density-spacious .crm-card,
.crm-density-spacious .crm-card-ios {
  border-radius: calc(var(--radius-apple, 22px) + 2px) !important;
}

/* 外观系统：阴影 / 玻璃 / 动效 / 对齐 */
html[data-crm-shadow="none"] .crm-card-ios,
html[data-crm-shadow="none"] .crm-card,
html[data-crm-shadow="none"] .crm-sidebar-float,
html[data-crm-shadow="none"] .liquid-glass {
  box-shadow: none !important;
}
html[data-crm-shadow="deep"] .crm-card-ios,
html[data-crm-shadow="deep"] .crm-card {
  box-shadow: var(--crm-card-shadow) !important;
}
html[data-crm-glass="flat"] .liquid-glass,
html[data-crm-glass="flat"] .crm-sidebar-float,
html[data-crm-glass="flat"] .crm-topbar,
html[data-crm-glass="flat"] .crm-bottom-nav {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  background: var(--crm-card, #fff) !important;
}
html[data-crm-glass="strong"] .liquid-glass,
html[data-crm-glass="strong"] .crm-sidebar-float,
html[data-crm-glass="strong"] .crm-topbar {
  backdrop-filter: blur(36px) saturate(200%) !important;
  -webkit-backdrop-filter: blur(36px) saturate(200%) !important;
}
html[data-crm-motion="reduce"] *,
html[data-crm-motion="reduce"] *::before,
html[data-crm-motion="reduce"] *::after {
  animation: none !important;
  transition: none !important;
  scroll-behavior: auto !important;
}
html[data-crm-align="left"] .crm-content-inner {
  margin-left: 0 !important;
  margin-right: auto !important;
  max-width: var(--content-max, 1080px) !important;
}
.crm-app-shell.crm-table-compact table td,
.crm-app-shell.crm-table-compact .crm-table td {
  padding-top: 6px !important;
  padding-bottom: 6px !important;
}
.crm-nav-item svg,
.crm-nav-icon svg,
.crm-icon-btn svg,
.crm-bottom-nav-item svg,
.crm-page-title-icon svg,
.crm-btn-icon,
.crm-module-icon-well svg {
  stroke-width: var(--crm-icon-stroke, 1.75);
}
.crm-bottom-nav-item.is-on svg {
  stroke-width: calc(var(--crm-icon-stroke, 1.75) + 0.35);
}
.crm-bottom-nav-icon {
  display: inline-flex;
  width: 28px;
  height: 24px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}
.crm-bottom-nav-item.is-on .crm-bottom-nav-icon {
  background: color-mix(in srgb, var(--primary) 12%, transparent);
}
.crm-icon-badge {
  pointer-events: none;
  box-shadow: 0 0 0 1.5px var(--ios-material-thick, #fff);
}
.crm-brand-mark {
  border-radius: 0 !important;
  box-shadow: none;
  object-fit: contain !important;
  background: transparent !important;
}
.crm-wordmark {
  height: 13px;
  width: auto;
  max-width: 96px;
  display: block;
  object-fit: contain;
}
.crm-lockup {
  height: 36px;
  width: auto;
  max-width: 240px;
  display: block;
  object-fit: contain;
}
html.dark .crm-lockup,
html.dark .crm-wordmark,
.dark .crm-lockup,
.dark .crm-wordmark {
  filter: invert(1);
}
html.dark .crm-brand-mark[src*="symbol-black"],
.dark .crm-brand-mark[src*="symbol-black"] {
  content: none;
  filter: invert(1);
}
.crm-ai-fab img {
  object-fit: contain;
}
.crm-icon-btn {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--ios-fill-tertiary);
  color: var(--ios-secondary-label);
  cursor: pointer;
  flex-shrink: 0;
}
.crm-icon-btn:hover {
  background: color-mix(in srgb, var(--primary) 10%, white);
  color: var(--primary);
}
.crm-nav-icon {
  background: transparent;
}
.crm-nav-icon svg,
.crm-icon-btn svg,
.crm-ai-fab svg,
.crm-page-title-icon svg {
  stroke-width: var(--crm-icon-stroke, 1.75);
}
.crm-ai-fab {
  border: 0.5px solid var(--ios-glass-border) !important;
}
.crm-settings-grid .crm-nav-icon {
  background: color-mix(in srgb, var(--primary) 8%, white);
  color: var(--primary);
}
.crm-density-compact .crm-dash-kpi { gap: 8px; }
.crm-density-compact .crm-page-head h2 { font-size: 1.28rem !important; }
.crm-settings-grid {
  align-items: start;
}
.crm-settings-panel {
  min-height: 480px;
  max-height: calc(100dvh - 168px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
@media (max-width: 900px) {
  .crm-settings-grid { grid-template-columns: 1fr !important; }
  .crm-settings-panel { max-height: none; }
}

.crm-qcf-bridge { margin-bottom: 14px; }
.crm-qcf-head { display:flex; justify-content:space-between; align-items:flex-start; gap:12px; flex-wrap:wrap; margin-bottom:10px; }
.crm-qcf-score { display:flex; flex-direction:column; align-items:flex-end; border:1px solid; border-radius:10px; padding:6px 10px; min-width:72px; }
.crm-qcf-score b { font-size:20px; font-weight:800; font-variant-numeric:tabular-nums; line-height:1.1; }
.crm-qcf-chain { display:flex; align-items:center; gap:6px; flex-wrap:wrap; margin-bottom:10px; }
.crm-qcf-arrow { color:var(--ios-label-secondary, #8a8790); font-size:12px; }
.crm-qcf-pill { border:0.5px solid var(--ios-separator, #E4E1D8); background:var(--ios-material-thick, #fff); border-radius:999px; padding:4px 10px; font-size:11.5px; font-weight:700; cursor:pointer; color:inherit; }
.crm-qcf-pill.is-here { box-shadow:0 0 0 2px rgba(47,107,92,.18); }
.crm-qcf-pill.is-ok { color:#2f6b5c; }
.crm-qcf-pill.is-gap { color:#b42318; }
.crm-qcf-kpis { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:8px; margin-bottom:10px; }
.crm-qcf-kpi { text-align:left; border:0.5px solid var(--ios-separator, #E4E1D8); background:#fafaf8; border-radius:10px; padding:8px 10px; cursor:pointer; }
.crm-qcf-kpi.is-hot { background:#fff6f4; border-color:#f0c4be; }
.crm-qcf-kpi-v { font-size:18px; font-weight:800; font-variant-numeric:tabular-nums; }
.crm-qcf-kpi-l { font-size:10.5px; color:#6b7280; font-weight:650; margin-top:1px; }
.crm-qcf-actions { display:flex; flex-wrap:wrap; gap:8px; margin-bottom:8px; }
.crm-qcf-list { display:flex; flex-direction:column; gap:4px; margin-top:4px; }
.crm-qcf-item { display:flex; align-items:center; gap:8px; width:100%; text-align:left; border:none; background:transparent; padding:6px 2px; cursor:pointer; border-radius:8px; }
.crm-qcf-item:hover { background:rgba(0,0,0,.04); }
.crm-qcf-item-t { flex:1; font-size:12px; min-width:0; }
.crm-qcf-lv { font-size:10px; font-weight:800; border-radius:6px; padding:1px 6px; flex-shrink:0; }
.crm-qcf-lv-高 { background:#fee4e2; color:#b42318; }
.crm-qcf-lv-中 { background:#fef0c7; color:#b54708; }
.crm-qcf-lv-低 { background:#e7f0ec; color:#2f6b5c; }
@media (max-width: 720px) {
  .crm-qcf-kpis { grid-template-columns:repeat(2,minmax(0,1fr)); }
}

.crm-appear-preview {
  display: grid;
  grid-template-columns: 52px 1fr;
  min-height: 88px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--crm-line, #e4e1d8);
  margin-bottom: 4px;
}
.crm-appear-preview-side { min-height: 88px; }
.crm-appear-preview-main { padding: 12px 14px; background: var(--crm-card, #fff); }
.crm-appear-preview-bar { height: 8px; width: 42%; border-radius: 99px; margin-bottom: 8px; }
.crm-appear-preview-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.crm-appear-preview-chips span {
  font-size: 10.5px;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 99px;
}
.crm-appear-section-title {
  font-size: 13.5px;
  font-weight: 750;
  margin: 18px 0 8px;
}
.crm-layout-preset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 8px;
}
.crm-layout-preset {
  text-align: left;
  border: 1.5px solid var(--crm-line, #e4e1d8);
  background: var(--crm-card, #fff);
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  color: inherit;
}
.crm-layout-preset b { display: block; font-size: 12.5px; font-weight: 750; margin-bottom: 4px; }
.crm-layout-preset span { display: block; font-size: 11px; color: var(--mute, #767c88); line-height: 1.35; }
.crm-layout-preset.is-on {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 16%, transparent);
}
.crm-appear-ui-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px 14px;
  margin-bottom: 8px;
}
.crm-appear-toggles {
  display: grid;
  gap: 8px;
  margin: 12px 0 4px;
}
.crm-appear-toggle {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--crm-line, #e4e1d8);
  background: var(--crm-card, #fff);
  cursor: pointer;
}
.crm-appear-toggle input { margin-top: 3px; accent-color: var(--primary); }
.crm-appear-toggle b { display: block; font-size: 12.5px; font-weight: 700; }
.crm-appear-toggle span { display: block; font-size: 11px; color: var(--mute, #767c88); margin-top: 2px; }
.crm-palette-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 10px;
}
.crm-palette-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 8px;
  border-radius: 12px;
  border: 2px solid var(--crm-line, #e4e1d8);
  background: var(--crm-card, #fff);
  cursor: pointer;
  text-align: left;
  color: inherit;
}
.crm-palette-card.is-on { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }
.crm-palette-grad { display: block; height: 42px; border-radius: 8px; }
.crm-palette-name { font-size: 12px; font-weight: 700; }
.crm-palette-on { font-size: 10.5px; font-weight: 700; color: var(--primary); }
.crm-accent-row { display: flex; flex-wrap: wrap; gap: 10px; }
.crm-accent-chip {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,.16);
  cursor: pointer;
  padding: 0;
}
.crm-accent-chip.is-on { box-shadow: 0 0 0 2px var(--primary); }
.crm-color-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 14px;
}
.crm-color-label { font-size: 12px; color: var(--mute, #767c88); font-weight: 650; margin-bottom: 8px; }
.crm-color-swatch { display: flex; align-items: center; gap: 10px; }
.crm-color-swatch-face {
  position: relative;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,.12);
  overflow: hidden;
  flex-shrink: 0;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.45);
}
.crm-color-swatch-face input[type="color"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  margin: 0;
  border: none;
  opacity: 0;
  cursor: pointer;
}
.crm-chip-row, .crm-model-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.crm-choice-chip, .crm-model-chip {
  min-height: 36px;
  padding: 6px 12px;
  border-radius: 10px;
  border: 1px solid var(--crm-line, #e4e1d8);
  background: var(--crm-card, #fff);
  color: inherit;
  font-weight: 650;
  font-size: 12.5px;
  cursor: pointer;
}
.crm-choice-chip.is-on, .crm-model-chip.is-on {
  border-color: var(--primary);
  background: var(--primary-soft, #e6f2f2);
  color: var(--primary);
}
.crm-model-chip { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11.5px; }
html[data-crm-theme="dark"] .crm-card {
  background: var(--crm-card) !important;
  border-color: var(--crm-line) !important;
}
@media (max-width: 720px) {
  .crm-color-fields { grid-template-columns: 1fr; }
}

/* ================================================================
   移动端 / iOS / Android / 平板 · 深度适配
   ================================================================ */
.crm-bottom-nav { display: none; }
.crm-modal-grab { display: none; }

@supports (padding: env(safe-area-inset-bottom)) {
  :root {
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
  }
}

/* 底部主导航 — 仅手机竖屏 */
@media (max-width: 767px) {
  .crm-bottom-nav {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 230;
    height: calc(56px + var(--safe-bottom));
    padding: 4px 4px var(--safe-bottom);
    background: var(--ios-material-thick, rgba(255,255,255,.92));
    backdrop-filter: blur(28px) saturate(180%);
    -webkit-backdrop-filter: blur(28px) saturate(180%);
    border-top: 0.5px solid var(--ios-separator, rgba(60,60,67,.12));
    box-shadow: 0 -8px 28px rgba(0,0,0,.06);
    justify-content: space-around;
    align-items: stretch;
  }
  .crm-bottom-nav-item {
    flex: 1 1 0;
    min-width: 0;
    min-height: 48px;
    border: none;
    background: transparent;
    color: var(--ios-secondary-label, #86868b);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-size: 10px;
    font-weight: 650;
    letter-spacing: 0.01em;
    cursor: pointer;
    border-radius: 12px;
    padding: 6px 2px 4px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }
  .crm-bottom-nav-item span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .crm-bottom-nav-item.is-on {
    color: var(--primary);
  }
  .crm-bottom-nav-item:active {
    background: var(--ios-fill-tertiary, rgba(118,118,128,.08));
  }

  .crm-app-shell {
    padding-bottom: 0 !important;
  }
  .crm-main-pane {
    border-radius: 0 !important;
    border-left: none !important;
    border-right: none !important;
    border-bottom: none !important;
  }
  .crm-content-inner {
    padding-bottom: calc(72px + var(--safe-bottom) + 12px) !important;
  }

  /* AI FAB 抬高，避开底栏 */
  .crm-ai-fab {
    right: max(14px, var(--safe-right)) !important;
    bottom: calc(72px + var(--safe-bottom)) !important;
    width: 52px !important;
    height: 52px !important;
  }

  /* AI 面板：全宽底部 sheet */
  .crm-ai-panel {
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    bottom: 0 !important;
    width: 100% !important;
    max-width: none !important;
    max-height: min(88dvh, calc(100dvh - var(--safe-top) - 12px)) !important;
    border-radius: 18px 18px 0 0 !important;
    animation: sheetUp .22s var(--ease-out) both;
    padding-bottom: var(--safe-bottom);
  }
  .crm-ai-panel-head { cursor: default !important; min-height: 48px; }

  /* Toast 避开底栏 */
  .crm-toast {
    left: 12px !important;
    right: 12px !important;
    bottom: calc(72px + var(--safe-bottom) + 8px) !important;
    max-width: none !important;
    width: auto !important;
  }

  /* 弹窗：底部 sheet */
  .crm-modal-overlay,
  .crm-confirm-overlay {
    align-items: flex-end !important;
    justify-content: stretch !important;
    padding: 0 !important;
    padding-top: var(--safe-top) !important;
  }
  .crm-modal-sheet,
  .crm-confirm-sheet {
    max-width: none !important;
    width: 100% !important;
    max-height: min(92dvh, calc(100dvh - var(--safe-top) - 8px)) !important;
    border-radius: 18px 18px 0 0 !important;
    margin: 0 !important;
    animation: sheetUp .24s var(--ease-out) both;
    padding-bottom: calc(12px + var(--safe-bottom)) !important;
  }
  .crm-modal-grab {
    display: block;
    width: 40px;
    height: 4px;
    border-radius: 99px;
    background: rgba(60,60,67,.22);
    margin: 8px auto 0;
    flex-shrink: 0;
  }
  .crm-modal-head {
    padding: 10px 16px 12px !important;
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 2;
  }
  .crm-modal-body {
    padding: 14px 16px 22px !important;
  }
  .crm-confirm-sheet { padding: 18px 18px calc(18px + var(--safe-bottom)) !important; }
  .crm-confirm-sheet > div:last-child {
    flex-wrap: wrap;
  }
  .crm-confirm-sheet button {
    min-height: var(--touch-min);
    flex: 1 1 120px;
  }

  /* 顶栏更紧凑、触控友好 */
  .crm-topbar {
    min-height: calc(48px + max(0px, var(--safe-top) - 4px)) !important;
    padding-top: max(6px, calc(var(--safe-top) * 0.35)) !important;
    padding-left: max(10px, var(--safe-left)) !important;
    padding-right: max(10px, var(--safe-right)) !important;
    gap: 6px !important;
  }
  .crm-icon-btn {
    min-width: var(--touch-min);
    min-height: var(--touch-min);
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
  }
  .crm-search-wrap input {
    min-height: var(--touch-min) !important;
    font-size: 16px !important;
  }

  /* 侧栏抽屉：贴边全高 */
  .crm-sidebar-float {
    top: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    width: min(86vw, 340px) !important;
    max-width: 340px !important;
    border-radius: 0 var(--radius-apple) var(--radius-apple) 0 !important;
    padding-top: var(--safe-top);
    padding-bottom: calc(8px + var(--safe-bottom));
  }
  .crm-sidebar-float.closed {
    transform: translateX(-105%) !important;
  }

  /* 表格与卡片 */
  .crm-content-inner table {
    min-width: 560px;
    font-size: 12.5px;
  }
  .crm-content-inner div:has(> table),
  .crm-table-scroll {
    margin-left: -4px;
    margin-right: -4px;
    padding-left: 4px;
    padding-right: 4px;
  }

  /* 设置：侧栏变顶部横向滚动 */
  .crm-settings-grid {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }
  .crm-settings-grid > .crm-card:first-child {
    position: sticky;
    top: 0;
    z-index: 5;
    padding: 6px !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .crm-settings-grid > .crm-card:first-child::-webkit-scrollbar { display: none; }
  .crm-settings-grid > .crm-card:first-child .crm-nav-group {
    display: inline-flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 4px;
    border: none !important;
    margin: 0 !important;
    padding: 0 4px !important;
    vertical-align: top;
  }
  .crm-settings-grid > .crm-card:first-child .crm-nav-group-title {
    display: none;
  }
  .crm-settings-grid > .crm-card:first-child .crm-nav-item {
    flex: 0 0 auto;
    margin: 0;
    white-space: nowrap;
    min-height: 40px;
    padding: 8px 12px;
  }
  .crm-settings-panel {
    max-height: none !important;
    min-height: 0 !important;
    padding: 16px !important;
  }

  /* 表单网格单列 */
  .crm-modal-body [style*="grid-template-columns"],
  .crm-settings-panel [style*="grid-template-columns: 1fr 1fr"],
  .crm-color-fields {
    grid-template-columns: 1fr !important;
  }

  /* 防止 iOS 双击缩放误触（保留 pinch） */
  .crm-app-shell {
    touch-action: manipulation;
  }

  /* 登录页 */
  .crm-login-wrap,
  .crm-login-card {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    border-radius: 0 !important;
    min-height: 100dvh;
    padding: max(24px, var(--safe-top)) 20px calc(28px + var(--safe-bottom)) !important;
  }
}

/* 手机横屏：底栏略矮、侧栏仍抽屉 */
@media (max-width: 767px) and (orientation: landscape) {
  .crm-bottom-nav {
    height: calc(48px + var(--safe-bottom));
  }
  .crm-bottom-nav-item { min-height: 40px; font-size: 9.5px; gap: 0; }
  .crm-bottom-nav-item svg { width: 18px; height: 18px; }
  .crm-content-inner {
    padding-bottom: calc(60px + var(--safe-bottom) + 10px) !important;
  }
  .crm-ai-fab {
    bottom: calc(58px + var(--safe-bottom)) !important;
  }
  .crm-ai-panel {
    max-height: min(94dvh, calc(100dvh - 8px)) !important;
  }
}

/* 平板竖屏 (768–1023)：可展开侧栏标签，触控更大 */
@media (min-width: 768px) and (max-width: 1023px) {
  .crm-bottom-nav { display: none !important; }
  .crm-ai-fab {
    right: max(18px, var(--safe-right)) !important;
    bottom: max(22px, var(--safe-bottom)) !important;
  }
  .crm-page-search-input {
    min-width: 180px;
    min-height: 40px;
  }
  .crm-modal-overlay {
    padding: 24px !important;
    align-items: center !important;
  }
  .crm-modal-sheet {
    max-height: calc(100dvh - 48px) !important;
    border-radius: 16px !important;
  }
  .crm-settings-grid {
    grid-template-columns: 200px 1fr !important;
  }
  .crm-content-inner table { min-width: 0; }
}

/* 大平板 / 小笔电横屏 */
@media (min-width: 900px) and (max-width: 1199px) {
  .crm-dashboard-grid { grid-template-columns: 1fr 260px; }
}

/* Android Chrome 地址栏动态高度 */
@media (max-width: 767px) {
  .crm-app-shell,
  .crm-main-pane,
  html, body, #root {
    height: 100dvh;
    max-height: 100dvh;
  }
}

/* 减少动效 */
@media (prefers-reduced-motion: reduce) {
  .crm-modal-sheet,
  .crm-confirm-sheet,
  .crm-ai-panel,
  .crm-bottom-nav-item {
    animation: none !important;
    transition: none !important;
  }
}

/* 高对比 / 深色外观时底栏 */
html[data-crm-theme="dark"] .crm-bottom-nav {
  background: rgba(28,28,30,.94);
  border-top-color: #3a3a3c;
}
html[data-crm-theme="dark"] .crm-bottom-nav-item { color: #aeaeb2; }
html[data-crm-theme="dark"] .crm-bottom-nav-item.is-on { color: var(--primary); }
html[data-crm-theme="dark"] .crm-modal-sheet,
html[data-crm-theme="dark"] .crm-confirm-sheet,
html[data-crm-theme="dark"] .crm-ai-panel {
  background: #2c2c2e !important;
  color: #f2f2f7;
}

/* —— 结算公式提示条 —— */
.crm-settle-formula {
  letter-spacing: 0.01em;
}
@media (max-width: 767px) {
  .crm-settle-formula { font-size: 12.5px !important; padding: 10px 12px !important; }
}

/* —— 板块 AI 员工融合条 —— */
.crm-ai-staff-bar {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 0.5px solid var(--ios-separator, rgba(60,60,67,.12));
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--primary) 8%, #fff), #fff 55%),
    var(--ios-material-thick, #fff);
  box-shadow: 0 8px 24px rgba(13,79,79,.06);
}
.crm-ai-staff-main {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.crm-ai-staff-avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.crm-ai-staff-meta { flex: 1 1 160px; min-width: 0; }
.crm-ai-staff-name {
  font-size: 14px;
  font-weight: 800;
  color: var(--ios-label, #1d1d1f);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: baseline;
}
.crm-ai-staff-name span {
  font-size: 11px;
  font-weight: 650;
  color: var(--primary);
}
.crm-ai-staff-role {
  font-size: 12px;
  color: var(--ios-secondary-label, #86868b);
  margin-top: 2px;
  line-height: 1.4;
}
.crm-ai-staff-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.crm-ai-staff-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.crm-ai-staff-chip {
  border: 1px solid var(--crm-line, #e4e1d8);
  background: #fff;
  color: var(--ios-label, #1d1d1f);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 11.5px;
  font-weight: 650;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.crm-ai-staff-chip:hover { border-color: var(--primary); color: var(--primary); }
.crm-ai-staff-chip:disabled { opacity: .5; cursor: default; }
.crm-ai-staff-memory {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: 10px;
}
.crm-ai-staff-memory-label {
  font-size: 10.5px;
  font-weight: 750;
  color: var(--ios-secondary-label, #86868b);
}
.crm-ai-staff-memory-pill {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--primary) 8%, #f5f5f7);
  color: var(--ios-label, #1d1d1f);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.crm-ai-staff-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.crm-ai-staff-card {
  border: 0.5px solid var(--ios-separator, rgba(60,60,67,.12));
  border-radius: 12px;
  padding: 12px;
  background: var(--ios-material-thick, #fff);
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
}
.crm-ai-staff-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(13,79,79,.08);
}
.crm-ai-staff-card strong { display: block; font-size: 13.5px; }
.crm-ai-staff-card span {
  display: block;
  font-size: 11.5px;
  color: var(--ios-secondary-label, #86868b);
  margin-top: 4px;
  line-height: 1.4;
}
@media (max-width: 767px) {
  .crm-ai-staff-bar { margin-bottom: 12px; padding: 10px 12px; }
  .crm-ai-staff-actions { width: 100%; }
  .crm-ai-staff-actions > * { flex: 1 1 auto; min-height: 40px; }
  .crm-ai-staff-chip { min-height: 36px; }
}

/* —— 业务页 / 表单 / 键盘 / 触控加固 —— */
:root { --kb-inset: 0px; --touch-min: 44px; }

@media (max-width: 767px) {
  .crm-page-header {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
  }
  .crm-page-title { font-size: 20px !important; }
  .crm-page-actions {
    width: 100%;
    display: flex !important;
    flex-wrap: wrap;
    gap: 8px !important;
  }
  .crm-page-search { flex: 1 1 100%; }
  .crm-page-search-input,
  .crm-login-card input,
  .crm-login-card select,
  .crm-modal-body input,
  .crm-modal-body select,
  .crm-modal-body textarea,
  .crm-settings-panel input,
  .crm-settings-panel select,
  .crm-settings-panel textarea,
  .crm-content-inner input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
  .crm-content-inner select,
  .crm-content-inner textarea {
    font-size: 16px !important; /* 防 iOS 聚焦自动缩放 */
    min-height: var(--touch-min);
  }
  .crm-content-inner textarea { min-height: 88px; }
  .crm-filter-chips {
    flex-wrap: nowrap !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px !important;
    margin: 0 -4px;
    padding-left: 4px !important;
    padding-right: 4px !important;
  }
  .crm-filter-chips::-webkit-scrollbar { display: none; }
  .crm-filter-chips > span {
    flex: 0 0 auto;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
  }
  .crm-table-scroll {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    border-radius: 10px;
  }
  .crm-card-list-grid {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }
  .crm-card-list-grid > * {
    min-width: 0;
  }
  /* 键盘打开：抬高底栏与 FAB，避免遮挡输入 */
  body.crm-kb-open .crm-bottom-nav {
    transform: translateY(calc(var(--kb-inset) * 0.92));
    opacity: 0.35;
    pointer-events: none;
  }
  body.crm-kb-open .crm-ai-fab { display: none !important; }
  body.crm-kb-open .crm-content-inner {
    padding-bottom: calc(16px + var(--kb-inset) + var(--safe-bottom)) !important;
  }
  body.crm-kb-open .crm-modal-sheet,
  body.crm-kb-open .crm-ai-panel {
    max-height: calc(100dvh - var(--kb-inset) - 8px) !important;
    padding-bottom: calc(12px + var(--safe-bottom)) !important;
  }
  /* 登录页：小屏全高、大触控 */
  .crm-login-wrap {
    align-items: stretch !important;
    padding: 0 !important;
  }
  .crm-login-card {
    max-width: none !important;
    min-height: 100dvh;
    border-radius: 0 !important;
    padding: max(28px, var(--safe-top)) 20px calc(28px + var(--safe-bottom)) !important;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
  .crm-login-card button,
  .crm-login-card [role="button"] {
    min-height: var(--touch-min);
  }
}

/* 平板竖屏加强：卡片双列、触控 */
@media (min-width: 768px) and (max-width: 1023px) {
  .crm-card-list-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  .crm-page-title { font-size: 24px !important; }
  .crm-filter-chips > span { min-height: 40px; padding: 6px 14px !important; }
  .crm-content-inner {
    padding-left: max(16px, var(--safe-left)) !important;
    padding-right: max(16px, var(--safe-right)) !important;
  }
}

/* 大屏平板横屏仍隐藏底栏，侧栏常驻 */
@media (min-width: 768px) {
  body.crm-nav-open { overflow: auto; }
}

@media (max-width: 767px) {
  body.crm-nav-open {
    overflow: hidden;
    touch-action: none;
  }
  body.crm-nav-open .crm-backdrop.show {
    opacity: 1;
    pointer-events: auto;
  }
}


