/* CRM / Contatti desktop — layout (#dCrm-wrap); glass in mytap-glass.css */

#dCrm-wrap {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

#dCrm-wrap .mt-tile { display: flex; flex-direction: column; height: 100%; }

#dCrm-wrap .mt-dash-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  align-items: stretch;
  margin-bottom: 16px;
}

#dCrm-wrap .mt-dash-grid--top { margin-bottom: 16px; }
#dCrm-wrap .mt-dash-grid--list { align-items: start; margin-bottom: 0; }

#dCrm-wrap .mt-span-1 { grid-column: span 1; }
#dCrm-wrap .mt-span-3 { grid-column: span 3; }

#dCrm-wrap .mt-hero { padding: 26px 28px 24px; overflow: hidden; }
#dCrm-wrap .mt-hero-wave { position: absolute; top: -60px; right: -60px; width: 360px; height: 360px; z-index: 0; pointer-events: none; }
#dCrm-wrap .mt-hero-top { display: flex; align-items: flex-start; justify-content: space-between; position: relative; z-index: 1; }
#dCrm-wrap .mt-eyebrow { font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--mt-text-tertiary); margin-bottom: 4px; }
#dCrm-wrap .mt-hero-name { font-size: 32px; font-weight: 700; letter-spacing: -0.02em; color: var(--mt-text-primary); }
#dCrm-wrap .mt-hero-name span { font-size: 17px; font-weight: 600; color: var(--mt-text-secondary); margin-left: 6px; }
#dCrm-wrap .mt-hero-insight { font-size: 13.5px; color: var(--mt-text-secondary); margin-top: 9px; }
#dCrm-wrap .mt-hero-insight b { color: var(--mt-text-primary); font-weight: 600; }
#dCrm-wrap .mt-scope-tag { font-size: 12px; color: var(--mt-text-tertiary); font-weight: 600; text-align: right; }

#dCrm-wrap .mt-action-rail { padding: 22px 18px; display: flex; flex-direction: column; min-height: 100%; }
#dCrm-wrap .mt-action-rail-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--mt-text-tertiary); margin-bottom: 14px; position: relative; z-index: 1; }
#dCrm-wrap .mt-action-rail-list { display: flex; flex-direction: column; gap: 10px; flex: 1; position: relative; z-index: 1; margin-top: auto; }

#dCrm-wrap .mt-btn-rail {
  width: 100%;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  padding: 11px;
  border-radius: 999px;
  cursor: pointer;
  border: none;
  font-family: inherit;
}

#dCrm-wrap .mt-btn-rail--primary {
  color: #fff;
  background: linear-gradient(135deg, var(--mt-purple), var(--mt-purple-deep));
  box-shadow: 0 8px 20px rgba(124, 92, 246, 0.3);
}

#dCrm-wrap .mt-btn-rail--outline {
  color: var(--mt-text-primary);
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--mt-divider);
}

#dCrm-wrap .mt-crm-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

#dCrm-wrap .mt-crm-search {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--mt-glass-bg);
  border: 1px solid var(--mt-glass-border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 999px;
  padding: 10px 16px;
  min-width: 260px;
  color: var(--mt-text-tertiary);
  flex: 1;
  max-width: 380px;
}

#dCrm-wrap .mt-crm-search input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 13.5px;
  color: var(--mt-text-primary);
  width: 100%;
  font-family: inherit;
}

#dCrm-wrap .mt-filter-chips { display: flex; gap: 6px; flex-wrap: wrap; }

#dCrm-wrap .crm-group-pill.mt-filter-chip {
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--mt-text-secondary);
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid var(--mt-divider);
  cursor: pointer;
  font-family: inherit;
}

#dCrm-wrap .crm-group-pill.mt-filter-chip:hover { background: rgba(255, 255, 255, 0.8); }

#dCrm-wrap .crm-group-pill.mt-filter-chip.active {
  background: linear-gradient(135deg, rgba(124, 92, 246, 0.14), rgba(124, 92, 246, 0.05));
  color: var(--mt-purple-deep);
  border-color: rgba(124, 92, 246, 0.2);
}

#dCrm-wrap .crm-group-pill-add.mt-filter-chip {
  border-style: dashed;
}

#dCrm-wrap .mt-contact-panel { padding: 18px 20px 8px; }

#dCrm-wrap .mt-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  position: relative;
  z-index: 1;
}

#dCrm-wrap .mt-section-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--mt-text-primary);
}

#dCrm-wrap .dCrm-cc {
  border-bottom: 1px solid var(--mt-divider);
}

#dCrm-wrap .dCrm-cc:last-child { border-bottom: none; }

#dCrm-wrap .dCrm-cc .mt-contact-row {
  border-bottom: none;
}

#dCrm-wrap .dCrm-cc[data-open="1"] .mt-contact-row {
  background: rgba(124, 92, 246, 0.05);
  border-radius: 12px;
}

#dCrm-wrap .dCrm-cc-acc {
  margin: 4px 0 12px;
  border-radius: var(--mt-radius-md);
  overflow: hidden;
  border: 1px solid var(--mt-glass-border, rgba(255, 255, 255, 0.65));
  background: var(--mt-glass-bg, rgba(255, 255, 255, 0.58));
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

/* Dettaglio contatto espanso (desktop + popup pipeline) */
.mt-dashboard .mt-crm-detail {
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mt-dashboard .mt-crm-detail-badge {
  display: inline-flex;
  align-self: flex-start;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(124, 92, 246, 0.12);
  color: var(--mt-purple-deep);
}

.mt-dashboard .mt-crm-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.mt-dashboard .mt-crm-detail-kv {
  background: rgba(124, 92, 246, 0.06);
  border: 1px solid var(--mt-divider);
  border-radius: var(--mt-radius-sm);
  padding: 10px 12px;
  min-width: 0;
}

.mt-dashboard .mt-crm-detail-kv--full { grid-column: 1 / -1; }

.mt-dashboard .mt-crm-detail-kv-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--mt-text-tertiary);
  margin-bottom: 4px;
}

.mt-dashboard .mt-crm-detail-kv-val {
  font-size: 13px;
  font-weight: 500;
  color: var(--mt-text-primary);
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.45;
  white-space: pre-wrap;
}

.mt-dashboard .mt-crm-detail-kv-val a {
  color: var(--mt-purple-deep);
  font-weight: 600;
  text-decoration: none;
}

.mt-dashboard .mt-crm-detail-kv-val a:hover { text-decoration: underline; }

.mt-dashboard .mt-crm-detail-quick {
  display: flex;
  gap: 8px;
}

.mt-dashboard .mt-crm-detail-quick a {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 8px;
  border-radius: var(--mt-radius-sm);
  border: 1px solid var(--mt-divider);
  background: rgba(255, 255, 255, 0.5);
  text-decoration: none;
  color: var(--mt-text-secondary);
  font-size: 11px;
  font-weight: 600;
  transition: background 0.15s, border-color 0.15s;
}

.mt-dashboard .mt-crm-detail-quick a:hover {
  background: rgba(124, 92, 246, 0.08);
  border-color: rgba(124, 92, 246, 0.2);
}

.mt-dashboard .mt-crm-detail-quick-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: rgba(124, 92, 246, 0.1);
  color: var(--mt-purple-deep);
  display: flex;
  align-items: center;
  justify-content: center;
}

.mt-dashboard .mt-crm-detail-groups-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--mt-text-tertiary);
  margin-bottom: 8px;
}

.mt-dashboard .mt-crm-detail-groups-empty {
  font-size: 11px;
  color: var(--mt-text-tertiary);
  line-height: 1.45;
}

.mt-dashboard .mt-crm-detail-groups-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mt-dashboard .mt-crm-group-chip {
  --grp-color: var(--mt-purple);
  margin: 0;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid color-mix(in srgb, var(--grp-color) 55%, var(--mt-divider));
  background: rgba(255, 255, 255, 0.55);
  color: var(--mt-text-primary);
  font-family: inherit;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.mt-dashboard .mt-crm-group-chip.is-on {
  background: var(--grp-color);
  border-color: var(--grp-color);
  color: #fff;
}

.mt-dashboard .mt-crm-detail-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.mt-dashboard .mt-crm-detail-btn {
  padding: 11px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  border: 1px solid var(--mt-divider);
  background: rgba(255, 255, 255, 0.55);
  color: var(--mt-text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.mt-dashboard .mt-crm-detail-btn:hover {
  background: rgba(124, 92, 246, 0.06);
}

.mt-dashboard .mt-crm-detail-btn--danger {
  background: rgba(217, 66, 90, 0.08);
  color: #D9425A;
  border-color: rgba(217, 66, 90, 0.22);
}

.mt-dashboard .mt-crm-detail-btn--danger:hover {
  background: rgba(217, 66, 90, 0.12);
}

.mt-dashboard .mt-crm-detail-btn--primary {
  width: 100%;
  grid-column: 1 / -1;
  background: linear-gradient(135deg, var(--mt-purple), var(--mt-purple-deep));
  color: #fff;
  border: none;
  box-shadow: 0 6px 16px rgba(124, 92, 246, 0.25);
}

.mt-dashboard .mt-crm-detail-btn--primary:hover {
  filter: brightness(1.04);
  background: linear-gradient(135deg, var(--mt-purple), var(--mt-purple-deep));
}

.mt-crm-detail-loading {
  padding: 14px 16px;
  font-size: 13px;
  color: var(--mt-text-tertiary);
}

.mob-cc-acc .mt-crm-detail {
  border-radius: 0 0 18px 18px;
}

#dCrm-wrap .mt-contact-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 2px;
  border-bottom: 1px solid var(--mt-divider);
  position: relative;
  z-index: 1;
  cursor: pointer;
}

#dCrm-wrap .mt-contact-row:last-child { border-bottom: none; }
#dCrm-wrap .mt-contact-row:hover { background: rgba(124, 92, 246, 0.04); border-radius: 12px; }

#dCrm-wrap .mt-contact-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  flex-shrink: 0;
  background: linear-gradient(150deg, var(--mt-purple-soft), var(--mt-purple-deep));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 13.5px;
}

#dCrm-wrap .mt-contact-info { flex: 1; min-width: 0; }
#dCrm-wrap .mt-contact-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--mt-text-primary); }
#dCrm-wrap .mt-contact-meta { font-size: 12.5px; color: var(--mt-text-tertiary); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#dCrm-wrap .mt-contact-tags { display: flex; gap: 6px; margin-top: 7px; flex-wrap: wrap; }

#dCrm-wrap .mt-tag-pill {
  font-size: 10.5px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

#dCrm-wrap .mt-tag-pill--new { background: rgba(124, 92, 246, 0.12); color: var(--mt-purple-deep); }
#dCrm-wrap .mt-tag-pill--source { background: rgba(0, 0, 0, 0.045); color: var(--mt-text-secondary); border: 1px solid var(--mt-divider); }

#dCrm-wrap .mt-contact-right { flex-shrink: 0; text-align: right; padding-right: 6px; }
#dCrm-wrap .mt-contact-date { font-size: 11.5px; color: var(--mt-text-tertiary); white-space: nowrap; }
#dCrm-wrap .mt-contact-chevron { color: var(--mt-text-tertiary); flex-shrink: 0; }

#dCrm-wrap .mt-stack-tile { padding: 0; }
#dCrm-wrap .mt-stack-block { padding: 20px; position: relative; z-index: 1; }
#dCrm-wrap .mt-stack-block + .mt-stack-block { border-top: 1px solid var(--mt-divider); }
#dCrm-wrap .mt-stack-eyebrow { font-size: 11.5px; font-weight: 700; color: var(--mt-text-primary); margin-bottom: 6px; }
#dCrm-wrap .mt-stack-desc { font-size: 12px; color: var(--mt-text-secondary); margin-bottom: 13px; line-height: 1.5; }

#dCrm-wrap .mt-field-input {
  width: 100%;
  font-size: 13px;
  padding: 10px 12px;
  border-radius: var(--mt-radius-sm);
  border: 1px solid var(--mt-divider);
  background: rgba(255, 255, 255, 0.55);
  color: var(--mt-text-primary);
  margin-bottom: 10px;
  font-family: inherit;
  box-sizing: border-box;
}

#dCrm-wrap .mt-btn-primary-block {
  width: 100%;
  text-align: center;
  font-size: 12.5px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, var(--mt-purple), var(--mt-purple-deep));
  border: none;
  padding: 10px;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 8px 20px rgba(124, 92, 246, 0.28);
}

#dCrm-wrap .mt-tool-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 3px;
  cursor: pointer;
  border-radius: 10px;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

#dCrm-wrap .mt-tool-row:hover { background: rgba(124, 92, 246, 0.06); }

#dCrm-wrap .mt-tool-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: rgba(124, 92, 246, 0.09);
  color: var(--mt-purple-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

#dCrm-wrap .mt-tool-label { font-size: 13px; font-weight: 600; color: var(--mt-text-primary); }
#dCrm-wrap .mt-tool-sub { font-size: 11px; color: var(--mt-text-tertiary); margin-top: 1px; }
#dCrm-wrap .mt-tool-chevron { margin-left: auto; color: var(--mt-text-tertiary); flex-shrink: 0; }

#dCrm-wrap .mt-crm-empty { text-align: center; padding: 48px 24px; }
#dCrm-wrap .mt-crm-empty-title { font-size: 15px; font-weight: 700; color: var(--mt-text-primary); margin: 12px 0 6px; }
#dCrm-wrap .mt-crm-empty-sub { font-size: 13px; color: var(--mt-text-secondary); max-width: 320px; margin: 0 auto; line-height: 1.5; }

#dCrm-wrap .dCrm-cc.is-hidden { display: none !important; }

#dCrm-wrap .crm-notify-status { font-size: 11px; margin-top: 8px; color: var(--mt-text-secondary); }

@media (min-width: 901px) {
  #view-crm .desk-crm-header { display: none !important; }
  #view-crm #dCrm-wrap .crm-legacy-body { display: none !important; }
}

@media (max-width: 900px) {
  #dCrm-wrap .mt-dash-grid,
  #dCrm-wrap .mt-crm-toolbar { display: none !important; }
}

@media (max-width: 1080px) {
  #dCrm-wrap .mt-dash-grid { grid-template-columns: repeat(2, 1fr); }
  #dCrm-wrap .mt-span-1,
  #dCrm-wrap .mt-span-3 { grid-column: span 2; }
}

@media (max-width: 760px) {
  #dCrm-wrap .mt-dash-grid { grid-template-columns: 1fr; }
  #dCrm-wrap .mt-span-1,
  #dCrm-wrap .mt-span-3 { grid-column: span 1; }
  #dCrm-wrap .mt-contact-right { display: none; }
}
