.crm-v1 {
  --crm-master-padding: 14px;
}

.crm-v1 .crm-master-head {
  display: grid;
  gap: 10px;
  padding: 16px var(--crm-master-padding) 12px;
  border-bottom: 1px solid var(--ds-line);
}

.crm-v1 .crm-master-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 24px;
  color: var(--ds-text-secondary);
  font-size: 11px;
}

.crm-v1 .crm-customer-list {
  max-height: calc(100vh - 330px);
  overflow: auto;
  padding: 8px;
  scrollbar-width: thin;
}

.crm-v1 .crm-customer-row {
  appearance: none;
  width: 100%;
  min-height: 68px;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: 13px;
  background: transparent;
  color: var(--ds-text);
  text-align: left;
  font: inherit;
  cursor: pointer;
}

.crm-v1 .crm-customer-row:hover {
  background: var(--ds-fill);
}

.crm-v1 .crm-customer-row.active {
  background: var(--ds-accent-soft);
  border-color: color-mix(
    in srgb,
    var(--ds-accent) 18%,
    transparent
  );
}

.crm-v1 .crm-avatar {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: var(--ds-fill);
  color: var(--ds-text-secondary);
  font-size: 13px;
  font-weight: 750;
}

.crm-v1 .crm-customer-row.active .crm-avatar {
  background: var(--ds-accent);
  color: white;
}

.crm-v1 .crm-row-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.crm-v1 .crm-row-copy b {
  overflow: hidden;
  color: var(--ds-text);
  font-size: 12.5px;
  font-weight: 680;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crm-v1 .crm-row-copy span {
  overflow: hidden;
  color: var(--ds-text-secondary);
  font-size: 10.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crm-v1 .crm-row-signal {
  display: grid;
  justify-items: end;
  gap: 4px;
}

.crm-v1 .crm-row-signal strong {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.crm-v1 .crm-row-signal small {
  color: var(--ds-text-tertiary);
  font-size: 9px;
}

.crm-detail {
  min-height: 100%;
}

.crm-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 26px 28px 20px;
  border-bottom: 1px solid var(--ds-line);
}

.crm-detail-identity {
  min-width: 0;
}

.crm-detail-eyebrow {
  margin-bottom: 5px;
  color: var(--ds-text-secondary);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .10em;
  text-transform: uppercase;
}

.crm-detail-identity h2 {
  margin: 0;
  color: var(--ds-text);
  font-size: clamp(22px, 2vw, 29px);
  line-height: 1.12;
  letter-spacing: -.035em;
}

.crm-detail-identity p {
  margin: 7px 0 0;
  color: var(--ds-text-secondary);
  font-size: 12px;
}

.crm-detail-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.crm-detail-nav {
  padding: 12px 28px 0;
}

.crm-detail-body {
  padding: 20px 28px 30px;
}

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

.crm-kpi {
  min-height: 104px;
  padding: 15px;
}

.crm-kpi span {
  display: block;
  color: var(--ds-text-secondary);
  font-size: 10px;
  font-weight: 680;
}

.crm-kpi strong {
  display: block;
  margin-top: 8px;
  color: var(--ds-text);
  font-size: 25px;
  line-height: 1;
  letter-spacing: -.035em;
  font-variant-numeric: tabular-nums;
}

.crm-kpi small {
  display: block;
  margin-top: 7px;
  color: var(--ds-text-tertiary);
  font-size: 9.5px;
}

.crm-overview-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(250px, .75fr);
  gap: 12px;
  margin-top: 12px;
}

.crm-section {
  padding: 18px;
}

.crm-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.crm-section-head div {
  display: grid;
  gap: 3px;
}

.crm-section-head span {
  color: var(--ds-text-secondary);
  font-size: 9px;
  font-weight: 780;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.crm-section-head b {
  font-size: 14px;
  letter-spacing: -.01em;
}

.crm-signal-list,
.crm-relation-list {
  display: grid;
}

.crm-signal,
.crm-relation {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 55px;
  padding: 10px 0;
  border-top: 1px solid var(--ds-line);
}

.crm-signal:first-child,
.crm-relation:first-child {
  border-top: 0;
}

button.crm-signal,
button.crm-relation {
  appearance: none;
  border-left: 0;
  border-right: 0;
  border-bottom: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  font: inherit;
  cursor: pointer;
}

button.crm-signal:hover,
button.crm-relation:hover {
  background:
    linear-gradient(
      90deg,
      transparent,
      var(--ds-fill),
      transparent
    );
}

.crm-signal-copy,
.crm-relation-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.crm-signal-copy b,
.crm-relation-copy b {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crm-signal-copy span,
.crm-relation-copy span {
  overflow: hidden;
  color: var(--ds-text-secondary);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crm-health {
  min-width: 48px;
  text-align: right;
  font-size: 12px;
  font-weight: 750;
}

.crm-health.good {
  color: var(--ds-success);
}

.crm-health.watch {
  color: var(--ds-warning);
}

.crm-health.critical {
  color: var(--ds-danger);
}

.crm-contact-grid {
  display: grid;
  gap: 2px;
}

.crm-contact {
  display: grid;
  gap: 3px;
  padding: 11px 0;
  border-top: 1px solid var(--ds-line);
}

.crm-contact:first-child {
  border-top: 0;
}

.crm-contact span {
  color: var(--ds-text-secondary);
  font-size: 9px;
  font-weight: 680;
}

.crm-contact b {
  overflow-wrap: anywhere;
  font-size: 11.5px;
  font-weight: 620;
}

.crm-notes {
  margin-top: 12px;
  padding: 12px;
  border-radius: var(--ds-radius-md);
  background: var(--ds-fill);
  color: var(--ds-text-secondary);
  font-size: 11px;
  line-height: 1.55;
}

.crm-relations-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.crm-relations-grid--relationship .crm-section:last-child {
  grid-column: 1 / -1;
}

.crm-loading {
  min-height: 400px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  color: var(--ds-text-secondary);
}

.crm-loading i {
  width: 26px;
  height: 26px;
  border: 3px solid var(--ds-line);
  border-top-color: var(--ds-accent);
  border-radius: 999px;
  animation: crm-spin .7s linear infinite;
}

@keyframes crm-spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 1180px) {
  .crm-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .crm-overview-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .crm-v1 .crm-customer-list {
    max-height: 280px;
  }

  .crm-detail-head,
  .crm-detail-body {
    padding-left: 18px;
    padding-right: 18px;
  }

  .crm-detail-nav {
    padding-left: 18px;
    padding-right: 18px;
  }
}

@media (max-width: 640px) {
  .crm-kpis,
  .crm-relations-grid {
    grid-template-columns: 1fr;
  }

  .crm-relations-grid--relationship .crm-section:last-child {
    grid-column: auto;
  }

  .crm-detail-head {
    flex-direction: column;
  }

  .crm-detail-actions {
    width: 100%;
  }

  .crm-detail-actions .ds-button {
    flex: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .crm-loading i {
    animation: none;
  }
}


/* Customer Workspace v1
   Keep the first-glance summary quiet: a compact information strip,
   not a dashboard card wall. */
.crm-v1 .crm-kpis {
  display: flex;
  gap: 0;
  overflow: hidden;
  border: 1px solid var(--ds-line);
  border-radius: var(--ds-radius-lg);
  background: var(--ds-surface-subtle);
}

.crm-v1 .crm-kpi.ds-card {
  flex: 1 1 0;
  min-width: 0;
  min-height: 76px;
  padding: 13px 15px;
  border: 0;
  border-right: 1px solid var(--ds-line);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.crm-v1 .crm-kpi.ds-card:last-child {
  border-right: 0;
}

.crm-v1 .crm-kpi strong {
  margin-top: 5px;
  font-size: 20px;
}

.crm-v1 .crm-kpi small {
  margin-top: 4px;
}

@media (max-width: 720px) {
  .crm-v1 .crm-kpis {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .crm-v1 .crm-kpi.ds-card {
    border-right: 1px solid var(--ds-line);
    border-bottom: 1px solid var(--ds-line);
  }

  .crm-v1 .crm-kpi.ds-card:nth-child(2n) {
    border-right: 0;
  }

  .crm-v1 .crm-kpi.ds-card:nth-last-child(-n + 2) {
    border-bottom: 0;
  }
}


.crm-empty-compact {
  min-height: 108px;
  padding: 20px;
}

.crm-notes--standalone {
  margin-top: 0;
  min-height: 108px;
}


/* CRM relationship layer inside the unified Customer Workspace. */
.crm-row-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.crm-mini-action {
  min-height: 30px;
  width: 30px;
  min-width: 30px;
  border-radius: 9px;
}

.crm-layer-warning {
  margin-top: 12px;
  padding: 9px 11px;
  border-radius: var(--ds-radius-md);
  background: var(--ds-warning-soft);
  color: var(--ds-warning);
  font-size: 10.5px;
  line-height: 1.45;
}

.crm-activity-list {
  display: grid;
}

.crm-activity-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: flex-start;
  min-height: 58px;
  padding: 11px 0;
  border-top: 1px solid var(--ds-line);
}

.crm-activity-row:first-child {
  border-top: 0;
}

.crm-activity-icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--ds-fill);
  color: var(--ds-text-secondary);
  font-size: 11px;
  font-weight: 760;
}

.crm-activity-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.crm-activity-copy b {
  overflow: hidden;
  color: var(--ds-text);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crm-activity-copy span {
  overflow: hidden;
  color: var(--ds-text-secondary);
  font-size: 10.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crm-activity-copy small {
  color: var(--ds-text-tertiary);
  font-size: 9.5px;
}

.crm-followup-date {
  max-width: 128px;
  color: var(--ds-text-secondary);
  font-size: 10px;
  text-align: right;
  line-height: 1.3;
}

.crm-opportunities-section {
  padding: 0;
  overflow: hidden;
}

.crm-opportunities-section > .crm-section-head {
  margin: 0;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--ds-line);
}

.crm-opportunity-list {
  display: grid;
}

.crm-opportunity-row {
  appearance: none;
  width: 100%;
  min-height: 76px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  align-items: center;
  padding: 13px 20px;
  border: 0;
  border-top: 1px solid var(--ds-line);
  background: transparent;
  color: inherit;
  text-align: left;
  font: inherit;
}

.crm-opportunity-row:first-child {
  border-top: 0;
}

button.crm-opportunity-row {
  cursor: pointer;
}

button.crm-opportunity-row:hover {
  background: var(--ds-fill);
}

.crm-opportunity-main {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.crm-opportunity-main b {
  overflow: hidden;
  color: var(--ds-text);
  font-size: 12.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crm-opportunity-main span {
  overflow: hidden;
  color: var(--ds-text-secondary);
  font-size: 10.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crm-opportunity-main small {
  color: var(--ds-text-tertiary);
  font-size: 9.5px;
}

.crm-opportunity-side {
  min-width: 120px;
  display: grid;
  justify-items: end;
  gap: 7px;
}

.crm-opportunity-side strong {
  color: var(--ds-text);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.crm-modal-head {
  margin: 0 0 18px;
  padding-right: 34px;
}

.crm-modal-head span {
  display: block;
  margin-bottom: 5px;
  color: var(--ds-text-secondary);
  font-size: 9px;
  font-weight: 780;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.crm-modal-head h2 {
  margin: 0;
  color: var(--ds-text);
  font-size: 22px;
  letter-spacing: -.025em;
}

.crm-modal-head p {
  margin: 7px 0 0;
  color: var(--ds-text-secondary);
  font-size: 11px;
  line-height: 1.5;
}

.crm-form .field textarea {
  min-height: 82px;
}

.crm-check-row {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 36px;
}

.crm-check-row label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  color: var(--ds-text-secondary);
  font-size: 11px;
  cursor: pointer;
}

.crm-check-row input {
  width: auto;
}

@media (max-width: 720px) {
  .crm-opportunity-row {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .crm-opportunity-side {
    min-width: 0;
    justify-items: start;
  }

  .crm-followup-date {
    max-width: 100px;
  }
}


/* Customer Intelligence: explainable signals, not a dashboard wall. */
.crm-intelligence-section {
  margin: 16px 0 0;
  padding: 0;
  overflow: hidden;
}

.crm-intelligence-section > .crm-section-head {
  margin: 0;
  padding: 15px 18px 12px;
  border-bottom: 1px solid var(--ds-line);
}

.crm-intelligence-list {
  display: grid;
}

.crm-intelligence-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  padding: 13px 18px;
  border-top: 1px solid var(--ds-line);
}

.crm-intelligence-row:first-child {
  border-top: 0;
}

.crm-intelligence-copy {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.crm-intelligence-title {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.crm-intelligence-title b {
  min-width: 0;
  overflow: hidden;
  color: var(--ds-text);
  font-size: 12.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crm-intelligence-reason {
  max-width: 780px;
  color: var(--ds-text-secondary);
  font-size: 10.5px;
  line-height: 1.5;
}

.crm-intelligence-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  white-space: nowrap;
}

.crm-signal-seed {
  display: grid;
  gap: 3px;
  margin: -4px 0 16px;
  padding: 10px 12px;
  border: 1px solid var(--ds-line);
  border-radius: var(--ds-radius-md);
  background: var(--ds-surface-subtle);
}

.crm-signal-seed span {
  color: var(--ds-text-tertiary);
  font-size: 9px;
  font-weight: 760;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.crm-signal-seed b {
  color: var(--ds-text);
  font-size: 11.5px;
}

.crm-signal-seed small {
  color: var(--ds-text-secondary);
  font-size: 10px;
  line-height: 1.45;
}

@media (max-width: 760px) {
  .crm-intelligence-row {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .crm-intelligence-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .crm-intelligence-title {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .crm-intelligence-title b {
    white-space: normal;
  }
}


/* Unified Customer Timeline v1 */
.crm-detail-body--history {
  padding-top: 14px;
}

.crm-history-section {
  padding: 0;
  overflow: hidden;
}

.crm-history-head {
  display: grid;
  gap: 10px;
  padding: 14px 16px 11px;
  border-bottom: 1px solid var(--ds-line);
}

.crm-history-heading {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.crm-history-heading > span {
  color: var(--ds-text-secondary);
  font-size: 9px;
  font-weight: 780;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.crm-history-heading > b {
  color: var(--ds-text);
  font-size: 13.5px;
  letter-spacing: -.01em;
}

.crm-history-filter-wrap {
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 1px;
  scrollbar-width: none;
}

.crm-history-filter-wrap::-webkit-scrollbar {
  display: none;
}

.crm-history-filter {
  display: inline-flex;
  flex-flow: row nowrap;
  width: max-content;
  min-width: max-content;
  max-width: none;
  vertical-align: top;
}

.crm-history-filter button {
  flex: 0 0 auto;
  white-space: nowrap;
}

.crm-history-list {
  display: grid;
}

.crm-history-row {
  position: relative;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  gap: 11px;
  align-items: flex-start;
  min-height: 68px;
  padding: 11px 16px;
  border-top: 1px solid var(--ds-line);
}

.crm-history-row:first-child {
  border-top: 0;
}

.crm-history-rail {
  position: relative;
  align-self: stretch;
  display: flex;
  justify-content: center;
  padding-top: 6px;
}

.crm-history-rail::after {
  content: "";
  position: absolute;
  top: 18px;
  bottom: -18px;
  width: 1px;
  background: var(--ds-line);
}

.crm-history-row:last-child .crm-history-rail::after {
  display: none;
}

.crm-history-dot {
  position: relative;
  z-index: 1;
  width: 8px;
  height: 8px;
  border: 2px solid var(--ds-surface);
  border-radius: 999px;
  background: var(--ds-text-tertiary);
  box-shadow: 0 0 0 1px var(--ds-line);
}

.crm-history-dot.success {
  background: var(--ds-success);
}

.crm-history-dot.danger {
  background: var(--ds-danger);
}

.crm-history-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.crm-history-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.crm-history-meta .ds-badge {
  min-height: 22px;
  padding: 0 8px;
  font-size: 10px;
}

.crm-history-meta time {
  color: var(--ds-text-tertiary);
  font-size: 9.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.crm-history-copy > b {
  overflow: hidden;
  color: var(--ds-text);
  font-size: 12.5px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crm-history-copy > span:not(.crm-history-meta) {
  color: var(--ds-text-secondary);
  font-size: 10.5px;
  line-height: 1.4;
}

.crm-history-copy > small {
  color: var(--ds-text-tertiary);
  font-size: 9.5px;
  line-height: 1.35;
}

.crm-history-open {
  align-self: center;
  min-height: 34px;
  padding: 0 11px;
  font-size: 11px;
}

.crm-loading--compact {
  min-height: 220px;
}

@media (max-width: 760px) {
  .crm-detail-body--history {
    padding-top: 10px;
  }

  .crm-history-head {
    gap: 8px;
    padding: 12px 13px 10px;
  }

  .crm-history-row {
    grid-template-columns: 16px minmax(0, 1fr);
    gap: 9px;
    padding: 11px 13px;
  }

  .crm-history-open {
    grid-column: 2;
    justify-self: start;
  }

  .crm-history-copy > b {
    white-space: normal;
  }
}
