.customer-preview-page .customer-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--crm-customer-card-min)), 1fr));
  gap: var(--crm-grid-gap);
}
.customer-preview-toolbar { gap: 8px; }
.customer-preview-toolbar .search { flex: 0 1 260px; min-width: min(220px, 100%); }
.customer-preview-toolbar .counter { width: auto; margin: 0; white-space: nowrap; }

.customer-preview-grade-a { --customer-grade: var(--crm-grade-a); --customer-grade-soft: var(--crm-customer-fill-a); }
.customer-preview-grade-b { --customer-grade: var(--crm-grade-b); --customer-grade-soft: var(--crm-customer-fill-b); }
.customer-preview-grade-c { --customer-grade: var(--crm-grade-c); --customer-grade-soft: var(--crm-customer-fill-c); }

.customer-preview-card {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: var(--crm-avatar-list) minmax(0, 1fr);
  grid-template-rows: 24px 20px 20px;
  gap: 4px 12px;
  align-content: center;
  min-width: 0;
  min-height: 108px;
  padding: 16px;
  overflow: hidden;
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-md);
  background: var(--crm-surface);
  color: var(--crm-text);
  text-decoration: none;
  transition: border-color var(--crm-duration-feedback) var(--crm-ease);
}
.customer-preview-card::before {
  position: absolute;
  z-index: -1;
  inset: 0 auto 0 0;
  width: var(--customer-fill);
  background: var(--customer-grade-soft);
  content: '';
}
.customer-preview-card-head { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.customer-preview-card-head strong { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 16px; line-height: 24px; font-weight: 600; }
.customer-preview-card .avatar { grid-row: 1 / 4; align-self: center; width: var(--crm-avatar-list); height: var(--crm-avatar-list); border-radius: var(--crm-radius-sm); overflow: hidden; display: grid; place-items: center; background: var(--crm-avatar-bg); font-size: 24px; }
.customer-preview-card .avatar img, .customer-preview-detail-avatar img { width: 100%; height: 100%; object-fit: cover; }
.customer-preview-card p { min-width: 0; margin: 0; font-size: 14px; line-height: 20px; }
.customer-preview-budget { flex: 0 1 auto; min-width: 0; max-width: 66%; overflow: hidden; text-overflow: ellipsis; font-size: 16px; line-height: 24px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.customer-preview-community { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.customer-preview-line { display: flex; gap: 8px; min-width: 0; }
.customer-preview-line span { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.customer-preview-line span:first-child { flex: 0 1 auto; max-width: 50%; font-variant-numeric: tabular-nums; }
.customer-preview-line span + span { flex: 1; color: var(--crm-text); }
.customer-preview-clear { flex-shrink: 0; margin: -4px -8px -4px 0; }
.customer-preview-detail { max-width: 1100px; }
.customer-preview-profile-header { display: grid; grid-template-columns: 44px var(--crm-avatar-detail) minmax(0, 1fr) auto; align-items: center; gap: 8px 12px; margin-bottom: 16px; }
.customer-preview-detail-avatar { display: grid; place-items: center; width: var(--crm-avatar-detail); height: var(--crm-avatar-detail); padding: 0; overflow: hidden; border: 0; border-radius: var(--crm-radius-md); background: var(--crm-avatar-bg); color: var(--crm-text); font: inherit; font-size: 28px; font-weight: 600; cursor: pointer; }
.customer-preview-identity { min-width: 0; }
.customer-preview-identity h1 { margin: 0; overflow-wrap: anywhere; }
.customer-preview-identity .meta { display: flex; align-items: center; gap: 8px; margin: 2px 0 0; font-variant-numeric: tabular-nums; }
.customer-preview-grade-label { font-size: 14px; line-height: 20px; color: var(--customer-grade); font-weight: 600; }
.customer-preview-profile-actions { display: flex; align-items: center; gap: 4px; }
.customer-preview-add-task { flex-shrink: 0; }
.customer-preview-detail .section { margin-top: 16px; }
.customer-preview-detail .customer-preview-profile { margin-top: 0; }
.customer-preview-detail .section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.customer-preview-detail .section-head h2 { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 0; font-size: 18px; line-height: 26px; font-weight: 600; }
.customer-preview-detail .section-head .counter { font-size: 14px; font-weight: 400; }
.customer-preview-profile .field-grid { margin: 0; }
.customer-preview-profile .field-grid > div { min-width: 0; }
.customer-preview-profile dd { overflow-wrap: anywhere; white-space: pre-wrap; }
.customer-preview-composer { display: grid; gap: 8px; }
.customer-preview-composer textarea { display: block; width: 100%; min-height: 88px; resize: vertical; padding: 10px 12px; border: 1px solid var(--crm-border-control); border-radius: var(--crm-radius-sm); background: var(--crm-field); color: var(--crm-text); font: 400 16px/24px var(--crm-font-sans); box-sizing: border-box; }
.customer-preview-composer textarea::placeholder { color: var(--crm-text-muted); }
.customer-preview-composer-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.customer-preview-form-error { color: var(--crm-danger); margin: 0; font-size: 14px; line-height: 20px; }
.customer-preview-form-error:empty { display: none; }
.customer-preview-attachments { display: flex; flex-wrap: wrap; gap: 8px; }
.customer-preview-attachment { position: relative; width: 72px; height: 72px; }
.customer-preview-attachment a { display: block; width: 100%; height: 100%; overflow: hidden; border-radius: 6px; background: var(--crm-surface-subtle); }
.customer-preview-attachment img { width: 100%; height: 100%; object-fit: cover; }
.customer-preview-remove { position: absolute; top: -4px; right: -4px; color: var(--crm-on-dark); background: var(--crm-brand); border-radius: var(--crm-radius-sm); }
.customer-preview-history .customer-preview-records { display: block; }
.customer-preview-record { position: relative; padding: 0 0 16px 16px; margin: 0; border: 0; border-left: 1px solid var(--crm-border); border-radius: 0; background: transparent; }
.customer-preview-record::before { position: absolute; left: -4px; top: 16px; width: 7px; height: 7px; border-radius: 50%; background: var(--crm-brand); content: ''; }
.customer-preview-record:last-child { padding-bottom: 4px; }
.customer-preview-record-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.customer-preview-record-top time { color: var(--crm-text-muted); font-size: 14px; line-height: 20px; font-variant-numeric: tabular-nums; }
.customer-preview-record-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 16px; line-height: 24px; margin: 0 0 8px; max-width: 75ch; }
.customer-preview-record-text:empty { display: none; }
.customer-preview-pin { flex-shrink: 0; color: var(--crm-text-muted); font-size: 14px; }
.customer-preview-pin.is-pinned { color: var(--crm-brand); }
.customer-preview-expand { margin-left: 16px; }
.customer-preview-expand[aria-expanded="true"] svg { transform: rotate(180deg); }
.customer-preview-created { position: relative; display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; color: var(--crm-text-muted); padding: 12px 0 0 16px; font-size: 14px; line-height: 20px; font-variant-numeric: tabular-nums; }
.customer-preview-created-dot { position: absolute; top: 18px; left: -3px; width: 7px; height: 7px; border-radius: 50%; background: var(--crm-border-control); }
.customer-preview-no-record { margin: 0; font-size: 14px; line-height: 20px; }
.customer-preview-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
@media (hover: hover) and (pointer: fine) {
  .customer-preview-card:hover { border-color: var(--customer-grade); }
  .customer-preview-detail-avatar:hover { outline: 2px solid var(--crm-brand); outline-offset: 2px; }
}
@media (max-width: 767px) {
  .customer-preview-toolbar .search { flex-basis: 240px; }
  .customer-preview-page .customer-preview-grid { gap: 12px; }
  .customer-preview-profile-header { grid-template-columns: 44px var(--crm-avatar-detail) minmax(0, 1fr); column-gap: 8px; margin-bottom: 12px; }
  .customer-preview-back { grid-column: 1; grid-row: 1; }
  .customer-preview-detail-avatar { grid-column: 2; grid-row: 1 / 3; }
  .customer-preview-identity { grid-column: 3; grid-row: 1; }
  .customer-preview-profile-actions { grid-column: 3; grid-row: 2; flex-wrap: wrap; }
  .customer-preview-profile-actions .btn { padding-inline: 8px; }
  .customer-preview-profile-actions .text-btn { padding-inline: 4px; }
  .customer-preview-identity .detail-title { font-size: 22px; line-height: 28px; }
  .customer-preview-detail .section { margin-top: 12px; }
  .customer-preview-detail .customer-preview-profile { margin-top: 0; }
}
