.contact-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.contact-card.selected {
  border-color: #1f6feb;
  box-shadow: 0 0 0 1px #1f6feb, var(--shadow);
}

.contact-card--needs-answer .contact-header,
.contact-card.has-open-question .contact-header {
  background: #b42318;
  color: #fff7f5;
}

.contact-card--customer .contact-header {
  background: #b8ccb4;
}

.contact-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 4px var(--s-3);
  padding: 10px 14px 8px;
  border-bottom: 1px solid var(--border);
  background: #dfe8df;
}

.contact-name {
  font-weight: 800;
  font-size: var(--fs-md);
}

.contact-label {
  font-weight: 700;
}

.contact-name-btn {
  border: 0;
  background: transparent;
  color: inherit;
  font-family: inherit;
  padding: 0;
  cursor: pointer;
  text-align: left;
}

.contact-name-btn.contact-name {
  font-size: var(--fs-md);
  font-weight: 800;
}

.contact-name-btn:disabled {
  cursor: default;
  opacity: 0.75;
}

.contact-name-row {
  display: inline-flex;
  align-items: baseline;
}

.status-icon {
  width: auto;
  height: 19px;
  margin-left: 6px;
  object-fit: contain;
  vertical-align: text-bottom;
}

.contact-badges {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
}

.contact-status {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid transparent;
}

.badge--star {
  background: #eef5ff;
  border-color: #bdd5ff;
  color: #2858b9;
}

.badge--flag {
  background: #fff0ef;
  border-color: #f0c1bc;
  color: #b23028;
}

.badge--hold {
  background: #fff7dc;
  border-color: #efd78d;
  color: #7b5b0f;
}

.contact-header-details {
  grid-column: 1 / -1;
  display: grid;
  gap: 1px;
}

.contact-header-info-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
}

.contact-header-line {
  min-height: 0;
  padding: 0;
  margin: 0;
}

.contact-header-address {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  line-height: 1.3;
}

.contact-header-email {
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 240px;
}

.contact-header-phone {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.contact-header-attachment-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 2px;
}

.attachment-btn {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid #9aa99a;
  background: transparent;
  color: #4d5d52;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.attachment-btn.is-active {
  background: #6f8091;
  border-color: #6f8091;
  color: #fff;
}

.attachment-btn:disabled {
  opacity: 0.65;
  cursor: default;
}

.attachment-icon {
  width: 18px;
  height: 18px;
}

.contact-header .contact-meta {
  color: #33433a;
}

.contact-card--needs-answer .contact-header .contact-meta,
.contact-card.has-open-question .contact-header .contact-meta {
  color: #fff0eb;
}

.hold-btn {
  margin-left: auto;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid #8f6a17;
  background: #8f6a17;
  color: #fff6df;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.hold-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.contact-card-body {
  padding: var(--s-4);
  display: grid;
  gap: var(--s-2);
}

.contact-meta,
.editable-row {
  min-height: 40px;
  border: 0;
  border-radius: 0;
  padding: 2px 0;
  background: transparent;
  font-size: var(--fs-sm);
}

.contact-meta {
  color: var(--muted);
  line-height: 1.45;
}

.contact-card-body > .contact-meta + .contact-meta {
  margin-top: 2px;
}

.contact-header .contact-meta,
.contact-header .contact-header-line {
  min-height: 0;
  padding: 0;
  margin: 0;
  line-height: 1.2;
}

.editable-row {
  width: 100%;
  text-align: left;
  cursor: pointer;
}

.latest-comm {
  font-size: var(--fs-sm);
  color: #2d4159;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: #fff;
  padding: 9px 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.comm-section {
  margin-top: var(--s-1);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: #f8fafd;
  padding: var(--s-2);
  display: grid;
  gap: var(--s-2);
}

.comm-title {
  font-size: var(--fs-sm);
  font-weight: 700;
}

.comm-list {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: #fff;
  max-height: 260px;
  overflow-y: auto;
}

.comm-list::-webkit-scrollbar {
  width: 8px;
}

.comm-list::-webkit-scrollbar-thumb {
  background: #c7d2df;
  border-radius: 999px;
}

.comm-row {
  display: grid;
  grid-template-columns: 34px 20px minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--s-2);
  padding: 9px 10px;
  border-bottom: 1px solid #edf1f5;
}

.feed-recent-item {
  grid-template-columns: 34px 22px minmax(0, 1fr);
  font-size: var(--fs-sm);
  color: #32475f;
}

.comm-channel-icon {
  width: 22px;
  height: 22px;
  object-fit: contain;
  align-self: center;
  margin-right: 6px;
  justify-self: center;
}

.comm-row-text {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.comm-icon-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 4px;
  border-radius: 6px;
  background: #eef3f8;
  color: #4a5c70;
  font-size: 10px;
  font-weight: 700;
  margin-right: 6px;
}

.comm-author-chip {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  justify-self: start;
}

.comm-row:last-child {
  border-bottom: 0;
}

.avatar,
.comm-bubble {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
}

.comm-icon {
  font-size: 15px;
  text-align: center;
}

.comm-channel {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid #dbe4ee;
  background: #f4f8fc;
  font-size: 11px;
  font-weight: 700;
}

.comm-text {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.comm-date {
  color: var(--muted);
  font-size: 12px;
}

.comm-body-line {
  border: 0;
  background: transparent;
  text-align: left;
  width: 100%;
  font: inherit;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.comm-row--add {
  cursor: pointer;
  color: var(--muted);
  border: 1px dashed #cfdae5;
  border-radius: var(--r-md);
  margin: var(--s-2);
  min-height: 40px;
  display: flex;
  align-items: center;
  padding: 0 12px;
}

.comm-row--add:hover {
  background: #f8fbff;
}

.feed-quick-add-editor {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: #fff;
  padding: var(--s-2);
  display: grid;
  gap: var(--s-2);
}

.attachment-list {
  display: grid;
  gap: var(--s-2);
}

.attachment-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--s-2);
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: #fff;
}

.attachment-meta {
  min-width: 0;
  font-size: var(--fs-sm);
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-actions {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

.comm-add-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) auto;
  gap: var(--s-2);
}

.comm-textarea {
  min-height: 44px;
  resize: vertical;
}

@media (max-width: 640px) {
  .contact-header-info-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 2px;
  }

  .contact-header-email {
    max-width: 140px;
  }

  .comm-add-row {
    grid-template-columns: 1fr;
  }
}
