/* Enterprise CRM — Email inbox, lead workspace (Zoho / Monday inspired) */

.min-width-0 {
  min-width: 0;
}

.crm-enterprise-page {
  --ent-accent: #226DB4;
  --ent-accent-soft: #E8F0FF;
  --ent-border: #D1D5DB;
  --ent-muted: #6B7280;
  --ent-surface: #FFFFFF;
  --ent-canvas: #F1F5F9;
  --ent-unread: #1B5A94;
  --ent-shadow: none;
  --ent-shadow-lg: 0 8px 24px rgba(15, 28, 46, 0.08);
}

/* ── Shared entity avatar ── */
.crm-entity-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  flex-shrink: 0;
  color: #fff;
  background: linear-gradient(135deg, var(--crm-primary, #226DB4) 0%, var(--crm-primary-hover, #185487) 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.15);
}

.crm-entity-avatar.avatar-sm {
  width: 1.75rem;
  height: 1.75rem;
  font-size: 0.625rem;
}

.crm-entity-avatar.avatar-lg {
  width: 3rem;
  height: 3rem;
  font-size: 0.9375rem;
}

.crm-entity-avatar.avatar-email {
  background: linear-gradient(135deg, #0891b2 0%, #0284c7 100%);
}

.crm-entity-avatar.avatar-lead {
  background: linear-gradient(135deg, var(--crm-primary, #226DB4) 0%, var(--crm-primary-hover, #185487) 100%);
}

.crm-entity-avatar.avatar-queue {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
}

/* ── Enterprise toolbar / filter pills ── */
.crm-ent-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.crm-ent-filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.crm-ent-filter-pills .nav-link {
  padding: 0.35rem 0.85rem;
  font-size: 0.8125rem;
  font-weight: 600;
  border-radius: 999px;
  color: var(--ent-muted);
  border: 1px solid var(--ent-border);
  background: var(--ent-surface);
}

.crm-ent-filter-pills .nav-link:hover {
  color: var(--ent-accent);
  border-color: #c7d2fe;
  background: var(--ent-accent-soft);
}

.crm-ent-filter-pills .nav-link.active {
  color: #fff;
  background: linear-gradient(135deg, var(--crm-primary-hover, #185487) 0%, var(--crm-primary, #226DB4) 100%);
  border-color: transparent;
  box-shadow: 0 1px 2px rgba(79, 70, 229, 0.35);
}

.crm-ent-search-wrap {
  position: relative;
  min-width: min(100%, 20rem);
  flex: 1;
  max-width: 28rem;
}

.crm-ent-search-wrap .bi-search {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ent-muted);
  pointer-events: none;
}

.crm-ent-search-wrap .form-control {
  padding-left: 2.25rem;
  border-radius: 999px;
  border-color: var(--ent-border);
  font-size: 0.875rem;
}

.crm-ent-search-wrap .form-control:focus {
  border-color: #a5b4fc;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* ── KPI strip (enterprise variant) ── */
.crm-ent-kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.crm-ent-kpi {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  background: var(--ent-surface);
  border: 1px solid var(--ent-border);
  border-radius: 0.75rem;
  box-shadow: var(--ent-shadow);
}

.crm-ent-kpi-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.5rem;
  font-size: 1rem;
  flex-shrink: 0;
}

.crm-ent-kpi-icon.icon-primary { background: var(--ent-accent-soft); color: var(--ent-accent); }
.crm-ent-kpi-icon.icon-info { background: #ecfeff; color: #0891b2; }
.crm-ent-kpi-icon.icon-success { background: #ecfdf3; color: #059669; }
.crm-ent-kpi-icon.icon-warning { background: #fffaeb; color: #d97706; }
.crm-ent-kpi-icon.icon-danger { background: #fef2f2; color: #dc2626; }

.crm-ent-kpi-value {
  font-size: 1.375rem;
  font-weight: 700;
  line-height: 1.1;
  color: #0f172a;
}

.crm-ent-kpi-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--ent-muted);
  margin-top: 0.1rem;
}

/* ── Email inbox ── */
.crm-email-inbox-panel {
  background: var(--ent-surface);
  border: 1px solid var(--ent-border);
  border-radius: 0.75rem;
  box-shadow: var(--ent-shadow);
  overflow: hidden;
}

.crm-email-inbox-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--ent-border);
  background: var(--ent-canvas);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ent-muted);
}

.crm-email-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.crm-email-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: start;
  gap: 0.85rem;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--ent-border);
  text-decoration: none;
  color: inherit;
  transition: background 0.12s ease;
}

.crm-email-row:last-child {
  border-bottom: none;
}

.crm-email-row:hover {
  background: #f8fafc;
}

.crm-email-row.is-unread {
  background: linear-gradient(90deg, rgba(79, 70, 229, 0.06) 0%, transparent 100%);
  border-left: 3px solid var(--ent-unread);
  padding-left: calc(1rem - 3px);
}

.crm-email-row.is-unread .crm-email-subject {
  font-weight: 700;
  color: #0f172a;
}

.crm-email-unread-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--ent-unread);
  margin-top: 0.65rem;
  flex-shrink: 0;
}

.crm-email-unread-dot.is-read {
  background: transparent;
}

.crm-email-main {
  min-width: 0;
}

.crm-email-from {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 0.15rem;
}

.crm-email-subject {
  font-size: 0.9375rem;
  font-weight: 600;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.crm-email-preview {
  font-size: 0.8125rem;
  color: var(--ent-muted);
  margin-top: 0.2rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}

.crm-email-meta {
  text-align: right;
  flex-shrink: 0;
  min-width: 5.5rem;
}

.crm-email-time {
  font-size: 0.75rem;
  color: var(--ent-muted);
  white-space: nowrap;
}

.crm-email-badges {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.25rem;
  margin-top: 0.35rem;
}

.crm-email-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.crm-email-badge.badge-lead {
  background: #ecfdf3;
  color: #047857;
  border: 1px solid rgba(5, 150, 105, 0.2);
}

.crm-email-badge.badge-unread {
  background: var(--ent-accent-soft);
  color: var(--ent-unread);
  border: 1px solid rgba(79, 70, 229, 0.2);
}

/* ── Email reader (detail) ── */
.crm-email-reader {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 992px) {
  .crm-email-reader {
    grid-template-columns: minmax(0, 1fr) 18rem;
    align-items: start;
  }
}

.crm-email-reader-main {
  background: var(--ent-surface);
  border: 1px solid var(--ent-border);
  border-radius: 0.75rem;
  box-shadow: var(--ent-shadow);
  overflow: hidden;
}

.crm-email-reader-header {
  padding: 1.25rem 1.35rem;
  border-bottom: 1px solid var(--ent-border);
  background: linear-gradient(180deg, #fafbff 0%, #fff 100%);
}

.crm-email-reader-subject {
  font-size: 1.25rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.35;
  margin-bottom: 0.85rem;
}

.crm-email-participants {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
}

.crm-email-participant {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

.crm-email-participant-label {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ent-muted);
}

.crm-email-participant-value {
  font-size: 0.875rem;
  font-weight: 500;
  color: #334155;
}

.crm-email-body-card {
  padding: 1.35rem;
}

.crm-email-body-content {
  font-size: 0.9375rem;
  line-height: 1.65;
  color: #334155;
  white-space: pre-wrap;
  word-break: break-word;
}

.crm-email-sidebar-panel {
  background: var(--ent-surface);
  border: 1px solid var(--ent-border);
  border-radius: 0.75rem;
  box-shadow: var(--ent-shadow);
  overflow: hidden;
  position: sticky;
  top: calc(var(--topbar-height, 52px) + 1rem);
}

.crm-email-sidebar-panel .panel-header {
  padding: 0.75rem 1rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ent-muted);
  background: var(--ent-canvas);
  border-bottom: 1px solid var(--ent-border);
}

.crm-email-sidebar-panel .panel-body {
  padding: 0.85rem 1rem;
}

.crm-email-meta-row {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.8125rem;
}

.crm-email-meta-row:last-child {
  border-bottom: none;
}

.crm-email-meta-row dt {
  color: var(--ent-muted);
  font-weight: 500;
  margin: 0;
}

.crm-email-meta-row dd {
  margin: 0;
  text-align: right;
  font-weight: 600;
  color: #334155;
}

/* ── Lead list (enterprise table) ── */
.crm-leads-panel {
  background: var(--ent-surface);
  border: 1px solid var(--ent-border);
  border-radius: 0.75rem;
  box-shadow: var(--ent-shadow);
  overflow: hidden;
}

.crm-leads-panel .table-toolbar {
  padding: 1rem 1.1rem;
  border-bottom: 1px solid var(--ent-border);
  background: var(--ent-canvas);
}

.crm-leads-panel .table thead th {
  background: #f8fafc;
  border-bottom: 1px solid var(--ent-border);
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ent-muted);
  padding-top: 0.65rem;
  padding-bottom: 0.65rem;
  white-space: nowrap;
}

.crm-leads-panel .table tbody td {
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
  vertical-align: middle;
  border-bottom: 1px solid #f1f5f9;
}

.crm-leads-panel .table tbody tr:hover {
  background: #f8fafc;
}

.crm-lead-cell-primary {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.crm-lead-cell-text {
  min-width: 0;
}

.crm-lead-cell-name {
  font-weight: 600;
  color: #0f172a;
  text-decoration: none;
}

.crm-lead-cell-name:hover {
  color: var(--ent-accent);
}

.crm-lead-cell-sub {
  font-size: 0.75rem;
  color: var(--ent-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.crm-touch-progress {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 5rem;
}

.crm-touch-progress-bar {
  flex: 1;
  height: 0.35rem;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  min-width: 2.5rem;
}

.crm-touch-progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--crm-primary, #226DB4), var(--crm-primary-hover, #185487));
}

.crm-touch-progress-fill.is-complete {
  background: linear-gradient(90deg, #34d399, #059669);
}

.crm-touch-progress-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #475569;
  white-space: nowrap;
}

.crm-assignee-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.55rem 0.2rem 0.25rem;
  background: #f8fafc;
  border: 1px solid var(--ent-border);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  color: #475569;
}

/* ── Lead detail hero ── */
.crm-record-hero {
  background: var(--ent-surface);
  border: 1px solid var(--ent-border);
  border-radius: 0.75rem;
  box-shadow: var(--ent-shadow);
  padding: 1.25rem 1.35rem;
  margin-bottom: 1rem;
  border-left: 4px solid var(--ent-accent);
}

.crm-record-hero-top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.crm-record-hero-identity {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.crm-record-hero-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.25;
  margin: 0 0 0.35rem;
}

.crm-record-hero-ref {
  font-size: 0.8125rem;
  color: var(--ent-muted);
  margin-bottom: 0.5rem;
}

.crm-record-hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.65rem;
}

.crm-record-stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.65rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--ent-border);
}

.crm-record-stat {
  padding: 0.65rem 0.75rem;
  background: var(--ent-canvas);
  border-radius: 0.5rem;
  border: 1px solid var(--ent-border);
}

.crm-record-stat-value {
  font-size: 1.125rem;
  font-weight: 700;
  color: #0f172a;
}

.crm-record-stat-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ent-muted);
  margin-top: 0.1rem;
}

/* ── Assign queue (Monday-style cards) ── */
.crm-queue-board {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.crm-queue-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.15rem;
  background: var(--ent-surface);
  border: 1px solid var(--ent-border);
  border-radius: 0.75rem;
  box-shadow: var(--ent-shadow);
  border-left: 4px solid #059669;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.crm-queue-card:hover {
  box-shadow: var(--ent-shadow-lg);
  transform: translateY(-1px);
}

.crm-queue-card-body {
  min-width: 0;
}

.crm-queue-card-title {
  font-size: 1rem;
  font-weight: 700;
  color: #0f172a;
  text-decoration: none;
}

.crm-queue-card-title:hover {
  color: var(--ent-accent);
}

.crm-queue-report-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.35rem;
  padding: 0.2rem 0.55rem;
  background: var(--ent-accent-soft);
  color: var(--ent-unread);
  border-radius: 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
}

.crm-queue-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-top: 0.45rem;
  font-size: 0.8125rem;
  color: var(--ent-muted);
}

.crm-queue-card-meta span {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.crm-queue-card-actions {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 7.5rem;
}

.crm-queue-time {
  font-size: 0.75rem;
  color: var(--ent-muted);
  white-space: nowrap;
}

/* ── Compose email ── */
.crm-compose-panel {
  background: var(--ent-surface);
  border: 1px solid var(--ent-border);
  border-radius: 0.75rem;
  box-shadow: var(--ent-shadow);
  overflow: hidden;
}

.crm-compose-panel-header {
  padding: 0.85rem 1.15rem;
  border-bottom: 1px solid var(--ent-border);
  background: var(--ent-canvas);
  font-weight: 600;
  font-size: 0.875rem;
  color: #334155;
}

.crm-compose-ribbon {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--ent-border);
  background: linear-gradient(180deg, var(--ent-accent-soft) 0%, var(--ent-canvas) 100%);
}

.crm-compose-ribbon-primary,
.crm-compose-ribbon-secondary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.crm-compose-format-ribbon {
  align-items: center;
  background: #faf9f8;
  border-bottom: 1px solid var(--ent-border);
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.4rem 0.85rem;
}

.crm-compose-format-ribbon .btn {
  line-height: 1.2;
  padding: 0.2rem 0.45rem;
}

.crm-compose-font-select,
.crm-compose-size-select {
  max-width: 8.5rem;
  width: auto;
}

.crm-compose-meta-row {
  align-items: flex-start;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  justify-content: space-between;
}

.crm-compose-meta-fields {
  flex: 1 1 18rem;
  min-width: 0;
}

.crm-compose-action-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: flex-end;
  padding-top: 0.35rem;
}

.crm-compose-from-value {
  font-size: 0.9375rem;
  padding: 0.375rem 0;
}

.crm-compose-editor.is-ribbon-hosted {
  border-radius: 0.5rem;
}

.crm-compose-attachment-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.45rem 1rem 0;
}

.crm-compose-attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: var(--ent-accent-soft);
  border: 1px solid #c7d2fe;
  font-size: 0.8125rem;
  color: #334155;
}

.crm-email-advanced-filters {
  border-top: 1px solid var(--ent-border);
  background: #f8fafc;
}

.crm-email-advanced-filters-form {
  display: none;
  padding: 0.65rem 1rem 0.85rem;
}

.crm-email-advanced-filters.is-open .crm-email-advanced-filters-form {
  display: block;
}

.crm-email-ribbon-group .btn.active {
  background: var(--ent-accent-soft);
  border-color: #c7d2fe;
  color: #312e81;
}

.crm-email-active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.45rem 1rem;
  border-top: 1px solid var(--ent-border);
  background: #fff;
}

.crm-email-table-row.is-unread .crm-email-owner-name {
  font-weight: 700;
  color: #0f172a;
}

.crm-email-table-row.is-read .crm-email-owner-name {
  font-weight: 400;
  color: #64748b;
}

.crm-email-lead-link {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  max-width: 100%;
}

.crm-email-lead-link .small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crm-compose-panel-body {
  padding: 1.15rem 1.25rem;
}

.crm-compose-field-row {
  display: grid;
  grid-template-columns: 4rem 1fr;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid #f1f5f9;
}

.crm-compose-field-row:last-of-type {
  border-bottom: none;
}

.crm-compose-field-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--ent-muted);
}

.crm-compose-field-row .form-control,
.crm-compose-field-row .form-select {
  border: none;
  box-shadow: none;
  padding-left: 0;
  font-size: 0.9375rem;
}

.crm-compose-field-row .form-control:focus,
.crm-compose-field-row .form-select:focus {
  box-shadow: none;
}

.crm-compose-body-wrap {
  padding: 0.75rem 0 0;
}

.crm-compose-body-wrap textarea {
  border-radius: 0.5rem;
  min-height: 14rem;
  font-size: 0.9375rem;
  line-height: 1.6;
}

/* Monday-style rich compose editor */
.crm-compose-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 17rem;
  gap: 1rem;
  align-items: start;
}

.crm-compose-sidebar {
  background: var(--ent-surface);
  border: 1px solid var(--ent-border);
  border-radius: 0.75rem;
  box-shadow: var(--ent-shadow);
  padding: 1rem;
  position: sticky;
  top: calc(var(--topbar-height, 52px) + 1rem);
}

.crm-compose-sidebar-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ent-muted);
  margin-bottom: 0.65rem;
}

.crm-compose-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.45rem 0.5rem;
  border: 1px solid var(--ent-border);
  border-bottom: none;
  border-radius: 0.5rem 0.5rem 0 0;
  background: var(--ent-canvas);
}

.crm-compose-toolbar .btn {
  padding: 0.2rem 0.45rem;
  line-height: 1.2;
}

.crm-compose-editor {
  min-height: 16rem;
  max-height: 28rem;
  overflow-y: auto;
  padding: 0.85rem 1rem;
  border: 1px solid var(--ent-border);
  border-radius: 0 0 0.5rem 0.5rem;
  background: #fff;
  font-size: 0.9375rem;
  line-height: 1.65;
  color: #334155;
}

.crm-compose-editor:focus {
  outline: none;
  border-color: #a5b4fc;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.crm-compose-editor p {
  margin-bottom: 0.65rem;
}

.crm-compose-editor ul,
.crm-compose-editor ol {
  margin: 0 0 0.75rem 1.25rem;
}

.crm-email-body-html {
  font-size: 0.9375rem;
  line-height: 1.65;
  color: #334155;
}

.crm-email-body-html p {
  margin-bottom: 0.65rem;
}

/* ── Outlook-style email shell (tabs + ribbon) ── */
.crm-email-outlook-shell.is-folder-inbox {
  border-color: #c7d2fe;
  box-shadow: 0 1px 3px rgba(79, 70, 229, 0.08);
}

.crm-email-outlook-shell.is-folder-inbox .crm-email-folder-tabs {
  background: linear-gradient(180deg, var(--ent-accent-soft) 0%, var(--ent-canvas) 100%);
}

.crm-email-outlook-shell.is-folder-inbox .crm-email-tab-panel {
  background: linear-gradient(180deg, #f5f7ff 0%, #ffffff 140px);
}

.crm-email-outlook-shell.is-folder-inbox .crm-email-folder-tabs .nav-link.active {
  background: rgba(79, 70, 229, 0.08);
  border-bottom-color: var(--ent-accent);
  color: #312e81;
}

.crm-email-outlook-shell.is-folder-sent {
  border-color: #a7f3d0;
  box-shadow: 0 1px 3px rgba(16, 185, 129, 0.08);
}

.crm-email-outlook-shell.is-folder-sent .crm-email-folder-tabs {
  background: linear-gradient(180deg, #ecfdf5 0%, #f8fafc 100%);
}

.crm-email-outlook-shell.is-folder-sent .crm-email-tab-panel {
  background: linear-gradient(180deg, #f0fdf4 0%, #ffffff 140px);
}

.crm-email-outlook-shell.is-folder-sent .crm-email-folder-tabs .nav-link.active {
  background: rgba(16, 185, 129, 0.1);
  border-bottom-color: #059669;
  color: #065f46;
}

.crm-email-outlook-shell {
  background: var(--ent-surface);
  border: 1px solid var(--ent-border);
  border-radius: 0.75rem;
  box-shadow: var(--ent-shadow);
  overflow: hidden;
}

.crm-email-folder-tabs {
  background: var(--ent-canvas);
  border-bottom: 1px solid var(--ent-border);
  padding: 0 0.75rem;
  gap: 0.25rem;
}

.crm-email-folder-tabs .nav-link {
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  color: var(--ent-muted);
  font-weight: 600;
  padding: 0.85rem 1rem;
}

.crm-email-folder-tabs .nav-link:hover {
  color: #334155;
}

.crm-email-folder-tabs .nav-link.active {
  background: transparent;
  border-bottom-color: var(--ent-accent);
  color: #1e293b;
}

.crm-email-tab-panel {
  background: var(--ent-surface);
}

.crm-email-ribbon {
  align-items: center;
  background: #f8fafc;
  border-bottom: 1px solid var(--ent-border);
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
}

.crm-email-ribbon-group {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.crm-email-ribbon-label {
  color: var(--ent-muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.crm-email-ribbon-search {
  align-items: center;
  display: flex;
  gap: 0.35rem;
  min-width: 220px;
}

.crm-email-ribbon-search .bi-search {
  color: var(--ent-muted);
}

.crm-email-view-menu {
  min-width: 280px;
}

.crm-email-view-column-list {
  max-height: 260px;
  overflow-y: auto;
}

.crm-email-view-column-item {
  align-items: center;
  display: flex;
  gap: 0.5rem;
  justify-content: space-between;
  padding: 0.35rem 0;
}

.crm-email-sort-link {
  align-items: center;
  color: inherit;
  display: inline-flex;
  gap: 0.25rem;
  text-decoration: none;
}

.crm-email-sort-link:hover {
  color: var(--ent-accent);
}

.crm-email-sort-link.is-active {
  color: var(--ent-accent);
  font-weight: 700;
}

.crm-email-preview-cell {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crm-email-table .col-preview {
  width: 18rem;
}

.crm-email-table .col-count {
  width: 6rem;
}

.crm-email-table .col-mailbox {
  width: 10rem;
}

/* ── Outlook-style email table ── */
.crm-email-table-panel {
  background: var(--ent-surface);
  border: 1px solid var(--ent-border);
  border-radius: 0.75rem;
  box-shadow: var(--ent-shadow);
  overflow: hidden;
}

.crm-email-table-wrap {
  overflow-x: auto;
}

.crm-email-table {
  table-layout: fixed;
  width: 100%;
  font-size: 0.875rem;
}

.crm-email-table.is-compact {
  font-size: 0.8125rem;
}

.crm-email-table.is-compact .crm-email-table-row td {
  padding: 0.35rem 0.65rem;
}

.crm-email-outlook-shell.is-compact .crm-entity-avatar.avatar-sm {
  height: 1.45rem;
  width: 1.45rem;
  font-size: 0.6rem;
}

.crm-email-table {
  table-layout: fixed;
  width: 100%;
}

.crm-email-col-head {
  position: relative;
  user-select: none;
  overflow: visible;
}

.crm-email-col-resizer {
  cursor: col-resize;
  height: 100%;
  position: absolute;
  right: -2px;
  top: 0;
  width: 10px;
  z-index: 3;
}

.crm-email-col-resizer::after {
  background: transparent;
  content: "";
  display: block;
  height: 60%;
  margin: 20% auto 0;
  width: 2px;
}

.crm-email-col-resizer:hover::after,
.crm-email-col-resizer.is-dragging::after {
  background: var(--so-primary, #226DB4);
}

.crm-email-col-resizer:hover,
.crm-email-col-resizer.is-dragging {
  background: rgba(15, 108, 189, 0.12);
}

body.is-email-col-resizing {
  cursor: col-resize !important;
  user-select: none !important;
}

.crm-email-html-frame {
  border: 0;
  display: block;
  min-height: 180px;
  width: 100%;
  background: #fff;
}

.crm-email-body-card,
.crm-email-thread-item-body {
  background: #fff;
}

.crm-email-table thead th {
  background: var(--ent-canvas);
  border-bottom: 1px solid var(--ent-border);
  color: var(--ent-muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 0.65rem 0.85rem;
  text-transform: uppercase;
  white-space: nowrap;
}

.crm-email-table .col-status {
  width: 2rem;
}

.crm-email-table .col-party {
  width: 14rem;
}

.crm-email-table .col-date {
  width: 11rem;
}

.crm-email-table .col-lead {
  width: 5.5rem;
}

.crm-email-table-row td {
  border-bottom: 1px solid var(--ent-border);
  padding: 0.55rem 0.85rem;
  vertical-align: middle;
}

.crm-email-table-row:hover {
  background: #f8fafc;
}

.crm-email-table-row.is-unread {
  background: #f8fbff;
}

.crm-email-table-row.is-read {
  background: #fff;
}

.crm-email-table-row.is-unread .crm-email-party-name,
.crm-email-table-row.is-unread .crm-email-subject-line,
.crm-email-table-row.is-unread .crm-email-date-cell {
  font-weight: 700;
  color: #0f172a;
}

.crm-email-table-row.is-read .crm-email-party-name,
.crm-email-table-row.is-read .crm-email-subject-line {
  font-weight: 400;
  color: #475569;
}

.crm-email-table-row.is-read .crm-email-date-cell {
  font-weight: 400;
  color: #64748b;
}

.crm-email-table-row.is-unread .crm-email-preview-cell {
  font-weight: 600;
  color: #334155;
}

.crm-email-table-row.is-read .crm-email-preview-cell {
  font-weight: 400;
  color: #94a3b8;
}

.crm-email-table-row.is-unread .crm-email-unread-dot {
  background: var(--so-primary, #226DB4);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.crm-email-table-row.is-read .crm-email-unread-dot.is-read {
  background: transparent;
  box-shadow: none;
}

.crm-email-table-link {
  color: inherit;
  display: block;
  text-decoration: none;
}

.crm-email-party-name {
  display: inline-block;
  max-width: calc(100% - 2rem);
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
  white-space: nowrap;
}

.crm-email-subject-line {
  font-weight: inherit;
}

.crm-email-preview-inline {
  color: var(--ent-muted);
  font-weight: 400;
}

.crm-entity-avatar.avatar-sm {
  height: 1.65rem;
  width: 1.65rem;
  font-size: 0.65rem;
  margin-right: 0.35rem;
}

/* ── Outlook-style mail list (Inbox / Sent) ── */
.ol-mail-list-panel {
  background: #fff;
  border-top: 1px solid #e1dfdd;
}

.ol-mail-list {
  display: flex;
  flex-direction: column;
}

.ol-mail-row {
  align-items: flex-start;
  border-bottom: 1px solid #edebe9;
  color: #242424;
  display: flex;
  gap: 0.65rem;
  padding: 0.7rem 0.9rem;
  text-decoration: none !important;
}

.ol-mail-row:hover {
  background: #f5f5f5;
  color: #242424;
}

.ol-mail-row.is-unread {
  background: #f3f9fd;
}

.ol-mail-row.is-unread .ol-mail-party,
.ol-mail-row.is-unread .ol-mail-subject {
  font-weight: 700;
}

.ol-mail-unread-dot {
  background: var(--so-primary, #226DB4);
  border-radius: 50%;
  flex-shrink: 0;
  height: 0.5rem;
  margin-top: 0.55rem;
  width: 0.5rem;
}

.ol-mail-unread-dot.is-read {
  background: transparent;
}

.ol-mail-avatar {
  align-items: center;
  background: #d2d0ce;
  border-radius: 50%;
  color: #242424;
  display: inline-flex;
  flex-shrink: 0;
  font-size: 0.68rem;
  font-weight: 700;
  height: 2rem;
  justify-content: center;
  text-transform: uppercase;
  width: 2rem;
}

.ol-mail-main {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.12rem;
  min-width: 0;
}

.ol-mail-top {
  display: flex;
  gap: 0.75rem;
  justify-content: space-between;
}

.ol-mail-party {
  font-size: 0.875rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ol-mail-date {
  color: #605e5c;
  flex-shrink: 0;
  font-size: 0.75rem;
}

.ol-mail-subject {
  font-size: 0.875rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ol-mail-count {
  background: #edebe9;
  border-radius: 999px;
  color: #605e5c;
  font-size: 0.7rem;
  font-weight: 600;
  margin-left: 0.35rem;
  padding: 0.05rem 0.4rem;
}

.ol-mail-preview {
  color: #605e5c;
  font-size: 0.8125rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ol-mail-submeta {
  color: #8764b8;
  font-size: 0.75rem;
}

.ol-mail-owner.is-unassigned {
  color: #ca5010;
}

/* ── Outlook-style conversation reading pane ── */
.ol-reading-pane {
  --ol-blue: #226DB4;
  --ol-blue-hover: #115ea3;
  --ol-border: #e1dfdd;
  --ol-muted: #605e5c;
  --ol-canvas: #faf9f8;
  --ol-surface: #ffffff;
  background: var(--ol-surface);
  border: 1px solid var(--ol-border);
  border-radius: 4px;
  overflow: hidden;
}

.ol-command-bar {
  align-items: center;
  background: var(--ol-canvas);
  border-bottom: 1px solid var(--ol-border);
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.45rem 0.65rem;
}

.ol-cmd-btn {
  align-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: #242424;
  display: inline-flex;
  font-size: 0.8125rem;
  font-weight: 600;
  gap: 0.35rem;
  padding: 0.35rem 0.65rem;
  text-decoration: none;
}

.ol-cmd-btn:hover {
  background: #edebe9;
  color: #242424;
  text-decoration: none;
}

.ol-cmd-btn.ol-cmd-primary {
  background: var(--ol-blue);
  color: #fff;
}

.ol-cmd-btn.ol-cmd-primary:hover {
  background: var(--ol-blue-hover);
  color: #fff;
}

.ol-cmd-divider {
  background: var(--ol-border);
  height: 1.25rem;
  margin: 0 0.25rem;
  width: 1px;
}

.ol-cmd-spacer {
  flex: 1;
}

.ol-subject-row {
  border-bottom: 1px solid var(--ol-border);
  padding: 0.85rem 1rem 0.75rem;
}

.ol-subject {
  color: #242424;
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.3;
  margin: 0;
}

.ol-subject-meta {
  color: var(--ol-muted);
  font-size: 0.8125rem;
  margin-top: 0.3rem;
}

.ol-subject-meta a {
  color: var(--ol-blue);
  text-decoration: none;
}

.ol-subject-meta a:hover {
  text-decoration: underline;
}

.ol-conversation,
.ol-single-body {
  background: var(--ol-surface);
}

.ol-single-body {
  padding: 0 0 1.25rem;
}

.ol-body-block {
  padding: 1rem 1.15rem 0.35rem;
}

.ol-body-block.is-targeted {
  box-shadow: inset 3px 0 0 var(--ol-blue);
}

.ol-body-header {
  margin-bottom: 0.75rem;
}

.ol-body-from {
  color: #242424;
  font-size: 0.95rem;
}

.ol-body-meta {
  color: var(--ol-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  justify-content: space-between;
  font-size: 0.8125rem;
  margin-top: 0.25rem;
}

.ol-body-content {
  color: #242424;
  font-size: 0.9375rem;
  line-height: 1.55;
}

.ol-body-divider {
  border: 0;
  border-top: 1px solid var(--ol-border);
  margin: 1rem 0 0;
}

.ol-message {
  border-bottom: 1px solid var(--ol-border);
}

.ol-message:last-child {
  border-bottom: 0;
}

.ol-message.is-targeted {
  box-shadow: inset 3px 0 0 var(--ol-blue);
}

.ol-message-summary {
  align-items: center;
  background: transparent;
  border: 0;
  cursor: pointer;
  display: flex;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  text-align: left;
  width: 100%;
}

.ol-message-summary:hover {
  background: #f5f5f5;
}

.ol-message.is-expanded > .ol-message-summary {
  display: none;
}

.ol-avatar {
  align-items: center;
  background: #d2d0ce;
  border-radius: 50%;
  color: #242424;
  display: inline-flex;
  flex-shrink: 0;
  font-size: 0.7rem;
  font-weight: 700;
  height: 2rem;
  justify-content: center;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  width: 2rem;
}

.ol-avatar-lg {
  height: 2.35rem;
  width: 2.35rem;
}

.ol-message.is-outbound .ol-avatar {
  background: #cfe4fa;
  color: var(--so-primary, #226DB4);
}

.ol-summary-main {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.ol-summary-from-row {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.ol-summary-from {
  color: #242424;
  font-size: 0.875rem;
  font-weight: 650;
}

.ol-dir-chip {
  border-radius: 3px;
  font-size: 0.6875rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  line-height: 1;
  padding: 0.18rem 0.4rem;
  text-transform: uppercase;
}

.ol-dir-chip.is-sent {
  background: #e8f3fc;
  color: var(--so-primary, #226DB4);
}

.ol-dir-chip.is-received {
  background: #f3f2f1;
  color: #605e5c;
}

.ol-from-line .ol-dir-chip {
  margin-left: 0.4rem;
  vertical-align: middle;
}

.ol-to-label {
  color: #242424;
  font-weight: 600;
}

.ol-cc-sep {
  margin: 0 0.35rem;
}

.ol-summary-preview {
  color: var(--ol-muted);
  font-size: 0.8125rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ol-summary-time {
  color: var(--ol-muted);
  flex-shrink: 0;
  font-size: 0.75rem;
  white-space: nowrap;
}

.ol-message-detail {
  padding: 0.85rem 1rem 1rem;
}

.ol-message-header {
  align-items: flex-start;
  display: flex;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.ol-message-people {
  flex: 1;
  min-width: 0;
}

.ol-from-line {
  color: #242424;
  font-size: 0.9375rem;
}

.ol-email {
  color: var(--ol-muted);
  font-weight: 400;
  margin-left: 0.25rem;
}

.ol-to-line {
  color: var(--ol-muted);
  font-size: 0.8125rem;
  margin-top: 0.15rem;
}

.ol-message-time {
  color: var(--ol-muted);
  font-size: 0.75rem;
  white-space: nowrap;
}

.ol-message-body {
  padding-left: 3.1rem;
}

.ol-message-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.85rem;
  padding-left: 3.1rem;
}

.ol-empty {
  color: var(--ol-muted);
  padding: 1.5rem 1rem;
}

.crm-email-quote-collapse {
  border-top: 1px dashed var(--ol-border);
  margin-top: 0.65rem;
  padding-top: 0.35rem;
}

.crm-email-quote-toggle {
  color: var(--ol-blue) !important;
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: none !important;
}

.crm-email-quote-panel {
  background: var(--ol-canvas);
  border: 1px solid var(--ol-border);
  border-radius: 4px;
  margin-top: 0.35rem;
  padding: 0.65rem 0.75rem;
}

@media (max-width: 768px) {
  .ol-message-body,
  .ol-message-actions {
    padding-left: 0;
  }
}

.crm-compose-toolbar {
  flex-wrap: wrap;
  gap: 0.35rem;
}

@media (max-width: 992px) {
  .crm-compose-layout {
    grid-template-columns: 1fr;
  }
  .crm-compose-sidebar {
    position: static;
  }
}

@media (max-width: 768px) {
  .crm-email-msg-body,
  .crm-email-msg-actions {
    padding-left: 0;
  }
  .crm-email-row {
    grid-template-columns: auto 1fr;
  }
  .crm-email-meta {
    grid-column: 2;
    text-align: left;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    margin-top: -0.25rem;
  }
  .crm-email-badges {
    flex-direction: row;
    align-items: flex-start;
  }
  .crm-queue-card {
    grid-template-columns: 1fr;
  }
  .crm-queue-card-actions {
    width: 100%;
    flex-direction: row;
  }
  .crm-record-hero-top {
    flex-direction: column;
  }
}

/* ── Outlook-style popup windows ── */
body.is-email-popup {
  background: #f3f2f1;
}

.crm-email-popup-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.crm-email-popup-bar {
  align-items: center;
  background: #fff;
  border-bottom: 1px solid #e1dfdd;
  display: flex;
  gap: 0.75rem;
  justify-content: space-between;
  padding: 0.55rem 0.9rem;
  position: sticky;
  top: 0;
  z-index: 20;
}

.crm-email-popup-brand {
  align-items: center;
  color: #242424;
  display: inline-flex;
  font-size: 0.9rem;
  font-weight: 600;
  gap: 0.45rem;
}

.crm-email-popup-brand .bi {
  color: var(--so-primary, #226DB4);
}

.crm-email-popup-content {
  flex: 1;
  min-width: 0;
  padding: 0;
}

body.is-email-popup .crm-enterprise-page {
  padding: 0.75rem 1rem 1.25rem;
}

body.is-email-popup .page-header {
  margin-bottom: 0.75rem;
}

body.is-email-popup .ol-reading-pane {
  border: 0;
  box-shadow: none;
  min-height: calc(100vh - 3.5rem);
}

/* Column drag reorder */
.crm-email-col-head.is-draggable {
  cursor: grab;
}

.crm-email-col-head.is-dragging-col,
.crm-email-table.is-reordering-cols .crm-email-col-head.is-dragging-col {
  cursor: grabbing;
  opacity: 0.55;
}

.crm-email-col-head.is-drop-col {
  box-shadow: inset 2px 0 0 var(--so-primary, #226DB4);
}

.crm-email-view-column-item {
  cursor: grab;
}

.crm-email-view-column-item.is-dragging {
  opacity: 0.5;
}

.crm-email-view-column-item.is-drop-target {
  box-shadow: inset 0 2px 0 var(--so-primary, #226DB4);
}

.crm-email-view-drag {
  color: #605e5c;
  cursor: grab;
  padding: 0 0.15rem;
}
