/* CRM shares the COMS type, folder navigation, cards and table footer styles.
   Every rule is scoped to CRM, including dialogs mounted outside its page. */
.crm {
  color: #374151;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  min-width: 0;
}
.crm [hidden] { display: none !important; }
.crm .crm-card {
  min-width: 0;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 1px 2px rgb(0 0 0 / 5%);
}
.crm h2 { color: #111827; font-size: 20px; font-weight: 700; margin: 0 0 16px; }
.crm h3 { color: #111827; font-size: 16px; font-weight: 600; margin: 20px 0 12px; }
.crm p { overflow-wrap: anywhere; }
.crm .crm-nav { margin-top: 0; margin-bottom: 0; }
.crm #crm-content.settings-folder-panel { margin-top: -1px; border-top-left-radius: 0; border-top-right-radius: 0; animation: none; }
.crm .crm-nav.order-section-tabs-shell::after { left: 0; right: 0; }
.crm .crm-nav .settings-folder-tab { min-width: 150px; flex-basis: 150px; }
.crm .crm-actions,
.crm .crm-heading,
.crm .crm-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}
.crm .crm-heading,
.crm .crm-toolbar { justify-content: space-between; gap: 12px; }
.crm .crm-heading h2,
.crm .crm-actions h2,
.crm .crm-toolbar h2 { margin-bottom: 0; }
.crm .crm-actions > h2 { margin-right: auto; }
.crm .crm-actions > input { flex: 1 1 240px; min-width: 0; }

/* Keep folder and shared pagination buttons on their native COMS rules. */
.crm .crm-btn,
.crm button.primary,
.crm button.secondary,
.crm button.accent,
.crm button.danger,
.crm button.link {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  min-height: 38px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 8px 16px;
  background: #fff;
  color: #374151;
  font: inherit;
  font-weight: 500;
  line-height: 1.4;
  text-align: center;
  cursor: pointer;
  transition: background-color .15s, border-color .15s, color .15s;
}
.crm .crm-btn:hover:not(:disabled) { background: #f9fafb; border-color: #d1d5db; }
.crm .crm-btn.primary,
.crm button.primary,
.crm .crm-btn.active,
.crm .crm-btn[aria-pressed="true"] {
  background: #1e4ea8;
  border-color: #1e4ea8;
  color: #fff;
}
.crm .crm-btn.primary:hover:not(:disabled),
.crm button.primary:hover:not(:disabled),
.crm .crm-btn.active:hover:not(:disabled) { background: #193f89; border-color: #193f89; }
.crm .crm-btn.secondary,
.crm button.secondary { color: #374151; background: #fff; border-color: #e5e7eb; }
.crm .crm-btn.secondary:hover:not(:disabled),
.crm button.secondary:hover:not(:disabled) { background: #f9fafb; border-color: #d1d5db; }
.crm .crm-btn.accent,
.crm button.accent { color: #1e4ea8; background: #ffbc00; border-color: #ffbc00; }
.crm .crm-btn.accent:hover:not(:disabled),
.crm button.accent:hover:not(:disabled) { background: #e6a800; border-color: #e6a800; }
.crm .crm-btn.danger,
.crm button.danger { color: #b91c1c; border-color: #fecaca; background: #fff; }
.crm .crm-btn.danger:hover:not(:disabled),
.crm button.danger:hover:not(:disabled) { background: #fef2f2; }
.crm .crm-btn.link,
.crm button.link { color: #1e4ea8; padding: 4px 0; min-height: 28px; background: transparent; border-color: transparent; text-align: left; }
.crm .crm-btn.link:hover:not(:disabled),
.crm button.link:hover:not(:disabled) { color: #193f89; background: transparent; border-color: transparent; text-decoration: underline; }
.crm button:disabled { opacity: .5; cursor: not-allowed; }
.crm .crm-btn:focus-visible,
.crm button.primary:focus-visible,
.crm button.secondary:focus-visible,
.crm button.accent:focus-visible,
.crm button.link:focus-visible,
.crm button.danger:focus-visible {
  outline: 2px solid #1e4ea8;
  outline-offset: 2px;
}
.crm input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
.crm select:not([data-action="page-size"]),
.crm textarea {
  max-width: 100%;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
  color: #374151;
  font: inherit;
}
.crm input:focus,
.crm select:focus,
.crm textarea:focus { outline: none; border-color: #1e4ea8; box-shadow: 0 0 0 2px rgb(30 78 168 / 14%); }
.crm input::placeholder,
.crm textarea::placeholder { color: #9ca3af; }
.crm input:disabled,
.crm select:disabled,
.crm textarea:disabled { color: #6b7280; background: #f9fafb; }
.crm input[type="checkbox"],
.crm input[type="radio"] { accent-color: #1e4ea8; width: 16px; height: 16px; flex-shrink: 0; }
.crm textarea { resize: vertical; }
.crm .crm-filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-bottom: 20px; }
.crm .crm-filters label { display: grid; gap: 6px; font-size: 12px; font-weight: 500; flex: 1 1 150px; min-width: 0; max-width: 220px; }
.crm .crm-filters label:has(input[name="q"]) { flex-basis: 280px; max-width: 100%; }
.crm .crm-filters input,
.crm .crm-filters select { width: 100%; font-size: 14px; }
.crm .crm-filter-details { margin-bottom: 20px; }
.crm .crm-filter-details summary { color: #1e4ea8; cursor: pointer; font-weight: 500; padding: 8px 0; }
.crm .crm-filter-details .crm-filters { margin-top: 8px; }
.crm .crm-filters-compact { display: block; }
.crm .crm-filter-main { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.crm .crm-filter-main > label { display: grid; gap: 6px; flex: 1 1 150px; min-width: 0; max-width: 220px; font-size: 12px; font-weight: 500; }
.crm .crm-filter-main > .crm-filter-search { flex: 2 1 280px; max-width: 360px; }
.crm .crm-filter-main > .crm-btn { flex: 0 0 auto; }
.crm .crm-filters-compact .crm-filter-details { flex: 0 0 auto; margin: 0; }
.crm .crm-filters-compact .crm-filter-details[open] { flex-basis: 100%; }
.crm .crm-filters-compact .crm-filter-details summary { display: inline-flex; align-items: center; min-height: 38px; padding: 8px 16px; border: 1px solid #e5e7eb; border-radius: 8px; background: #fff; color: #374151; font-size: 14px; font-weight: 500; line-height: 1.4; list-style: none; }
.crm .crm-filters-compact .crm-filter-details summary::-webkit-details-marker { display: none; }
.crm .crm-filters-compact .crm-filter-details summary::after { content: '⌄'; margin-left: 7px; color: #1e4ea8; font-size: 16px; line-height: 1; }
.crm .crm-filters-compact .crm-filter-details[open] summary::after { transform: rotate(180deg); }
.crm .crm-filters-compact .crm-filter-details summary:hover { background: #f9fafb; border-color: #d1d5db; }
.crm .crm-filter-active { width: 6px; height: 6px; margin-left: 7px; border-radius: 999px; background: #1e4ea8; }
.crm .crm-filter-advanced { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-top: 12px; padding: 16px; border: 1px solid #dbe3ef; border-radius: 12px; background: #f8fafc; }
.crm .crm-filter-advanced label { display: grid; gap: 6px; min-width: 0; font-size: 12px; font-weight: 500; }
.crm .crm-view-switch { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; margin-bottom: 16px; background: #f3f4f6; border: 1px solid #e5e7eb; border-radius: 10px; }
.crm .crm-view-switch .crm-btn { min-height: 34px; border-color: transparent; padding: 6px 14px; background: transparent; }
.crm .crm-view-switch .crm-btn.primary,
.crm .crm-view-switch .crm-btn.active,
.crm .crm-view-switch .crm-btn[aria-pressed="true"] { background: #fff; border-color: #e5e7eb; color: #1e4ea8; box-shadow: 0 1px 2px rgb(0 0 0 / 5%); }
.crm .crm-view-switch .crm-btn.primary:hover:not(:disabled),
.crm .crm-view-switch .crm-btn.active:hover:not(:disabled) { background: #eff6ff; border-color: #dbeafe; }

.crm .crm-scroll { overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin; scrollbar-color: #9fb5df transparent; }
.crm table { width: 100%; border-collapse: collapse; text-align: left; white-space: nowrap; }
.crm th { padding: 12px 24px; border-bottom: 1px solid #e5e7eb; background: #f9fafb; font-size: 14px; font-weight: 600; color: #374151; }
.crm td { padding: 14px 24px; border-top: 1px solid #e5e7eb; max-width: 350px; overflow: hidden; text-overflow: ellipsis; }
.crm tbody tr:hover { background: #f9fafb; }
.crm td .crm-btn { padding: 6px 10px; min-height: 32px; margin-right: 4px; }
.crm td .crm-btn.link { padding-left: 0; }
.crm .crm-empty { padding: 48px 24px; color: #6b7280; text-align: center; white-space: normal; }
.crm .crm-table-footer { margin-top: 0; }
.crm .crm-scroll.order-list-scroll-area { scrollbar-width: none; }
.crm .crm-scroll.order-list-scroll-area::-webkit-scrollbar { width: 0; height: 0; }
.crm .crm-table-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; color: #4b5563; }
.crm .crm-page-size { display: inline-flex; align-items: center; gap: 8px; color: #4b5563; }
.crm .crm-pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }
.crm .crm-pagination .crm-btn { min-width: 36px; min-height: 36px; padding: 6px 12px; box-shadow: 0 1px 2px rgb(0 0 0 / 5%); }
.crm .crm-pagination .crm-btn[aria-current="page"] { color: #fff; background: #1e4ea8; border-color: #1e4ea8; }
.crm .crm-pagination .crm-btn:hover:not(:disabled):not([aria-current="page"]) { background: #eff6ff; border-color: #bfdbfe; color: #1d4ed8; }
.crm .crm-pagination .crm-btn:disabled { background: #f9fafb; color: #cbd5e1; opacity: 1; }
.crm .crm-pagination svg { width: 16px; height: 16px; }
.crm .crm-pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; }
.crm .crm-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 20px; }
.crm .crm-grid > .crm-card { margin-bottom: 0; }
.crm .crm-stat { color: #111827; font-size: 30px; font-weight: 700; line-height: 1.2; margin-top: 8px; }
.crm .crm-badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; background: #dbeafe; color: #1e40af; font-size: 12px; font-weight: 500; }
.crm .crm-badge[data-status="Converted"],
.crm .crm-badge[data-status="Completed"],
.crm .crm-badge[data-status="Active"] { background: #dcfce7; color: #166534; }
.crm .crm-badge[data-status="Current"] { background: #dcfce7; color: #166534; }
.crm .crm-badge[data-status="Nurturing"],
.crm .crm-badge[data-status="Pending"] { background: #fef3c7; color: #92400e; }
.crm .crm-badge[data-status="Inactive"] { background: #f3f4f6; color: #4b5563; }
.crm .crm-pipeline { display: grid; grid-template-columns: repeat(4, minmax(240px, 1fr)); gap: 16px; overflow-x: auto; padding-bottom: 12px; scrollbar-width: thin; scrollbar-color: #9fb5df transparent; }
.crm .crm-lane { min-width: 0; min-height: 220px; border: 1px solid #e5e7eb; border-radius: 12px; padding: 12px; background: #f9fafb; }
.crm .crm-lane > h3 { display: flex; justify-content: space-between; gap: 8px; margin: 4px 0 16px; }
.crm .crm-lane .crm-card { padding: 16px; margin-bottom: 12px; border-radius: 12px; }
.crm .crm-lane .crm-card:last-child { margin-bottom: 0; }
.crm .crm-lane .crm-card .crm-btn.link { white-space: normal; justify-content: flex-start; }
.crm .crm-lane .crm-card select { width: 100%; margin-top: 12px; }
.crm .crm-pipeline-values { display: grid; gap: 7px; }
.crm .crm-pipeline-value { margin: 0; color: #4b5563; overflow-wrap: anywhere; }
.crm .crm-pipeline-value a { color: #1e4ea8; text-decoration: none; }
.crm .crm-pipeline-value a:hover { text-decoration: underline; }
.crm .crm-pipeline-lead-number .crm-btn { min-height: 24px; padding: 0; font-weight: 700; }
.crm .crm-pipeline-lead-name { color: #111827; font-weight: 600; }
.crm .crm-muted { color: #6b7280; font-size: 12px; font-weight: 400; }
.crm .crm-error,
.crm .crm-notice { padding: 12px 16px; border-radius: 8px; margin: 12px 0; white-space: pre-wrap; }
.crm .crm-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.crm .crm-notice { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.crm .crm-notice .crm-btn { margin: 8px 8px 0 0; }

dialog.crm { width: min(900px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); margin: auto; padding: 24px; border: 1px solid #e5e7eb; border-radius: 16px; background: #fff; overflow: auto; overscroll-behavior: contain; box-shadow: 0 25px 50px -12px rgb(0 0 0 / 25%); }
dialog.crm::backdrop { background: rgb(0 0 0 / 50%); }
dialog.crm .crm-dialog-header,
dialog.crm .crm-modal-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: -24px -24px 24px; padding: 20px 24px; border-bottom: 1px solid #e5e7eb; }
dialog.crm .crm-dialog-header h2,
dialog.crm .crm-modal-header h2 { min-width: 0; overflow-wrap: anywhere; margin: 0; }
dialog.crm .crm-modal-header > button { flex-shrink: 0; }
dialog.crm .crm-modal-body { min-width: 0; overflow: visible; }
dialog.crm .crm-dialog-footer,
dialog.crm .crm-modal-footer { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 24px; padding-top: 16px; border-top: 1px solid #e5e7eb; }
.crm .crm-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.crm .crm-form-grid > * { min-width: 0; }
.crm .crm-form-grid label { display: grid; gap: 8px; color: #374151; font-weight: 500; }
.crm .crm-form-grid input:not([type="checkbox"]):not([type="radio"]),
.crm .crm-form-grid select,
.crm .crm-form-grid textarea { width: 100%; }
.crm .crm-form-grid .wide { grid-column: 1 / -1; }
.crm .crm-form-grid select[multiple] { min-height: 108px; }
.crm .crm-form-grid small { color: #6b7280; font-size: 12px; font-weight: 400; }
.crm .crm-form-grid h3 { margin-top: 0; }
.crm .crm-detail { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 4px; }
.crm .crm-form-section,
.crm .crm-company-section,
.crm .crm-contact-selector { border-top: 1px solid #e5e7eb; padding-top: 16px; }
.crm .crm-company-section > [data-company-label] { margin: 12px 0; font-weight: 500; }
.crm .crm-company-connection-current { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px; border: 1px solid #86efac; border-radius: 10px; background: #f0fdf4; }
.crm .crm-company-connection-history { display: grid; gap: 8px; margin: 8px 0 0; padding: 0; list-style: none; }
.crm .crm-company-connection-history li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 0; border-bottom: 1px solid #e5e7eb; }
.crm .crm-company-connection-history small { color: #6b7280; }
.crm .crm-contact-selector { overflow: visible; }
.crm .crm-inline-contact,
.crm .crm-inline-form { margin-top: 12px; padding: 16px; border: 1px solid #e5e7eb; border-radius: 12px; background: #f9fafb; }
.crm .crm-inline-contact .crm-actions,
.crm .crm-inline-form .crm-actions { margin-top: 16px; margin-bottom: 0; }
.crm .crm-contact-picker { min-width: 0; }
.crm .crm-autocomplete { position: relative; min-width: 0; }
.crm .crm-autocomplete > input { width: 100%; }
.crm .crm-suggestions { max-height: 192px; overflow-y: auto; margin-top: 8px; border: 1px solid #e5e7eb; border-radius: 8px; background: #fff; box-shadow: 0 10px 15px -3px rgb(0 0 0 / 10%); }
.crm .crm-autocomplete > .crm-suggestions { position: absolute; z-index: 30; top: 100%; left: 0; right: 0; max-height: min(192px, 35dvh); overscroll-behavior: contain; }
.crm .crm-suggestions:empty { display: none; }
.crm .crm-suggestions > .crm-suggestion,
.crm .crm-suggestions > .crm-btn,
.crm .crm-suggestions > button,
.crm .crm-suggestions [role="option"] { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 3px; width: 100%; padding: 12px 16px; border: 0; border-bottom: 1px solid #f3f4f6; border-radius: 0; color: #374151; background: #fff; text-align: left; font: inherit; cursor: pointer; }
.crm .crm-suggestions > button:last-child { border-bottom: 0; }
.crm .crm-suggestions > button:hover,
.crm .crm-suggestions > button:focus-visible,
.crm .crm-suggestions [role="option"][aria-selected="true"] { background: #eff6ff; color: #1e4ea8; outline: none; }
.crm .crm-suggestions > p { padding: 12px 16px; }
.crm .crm-suggestion strong { font-weight: 500; }
.crm .crm-suggestion small { color: #6b7280; font-size: 12px; font-weight: 400; }
.crm .crm-contact-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 10px 0; }
.crm .crm-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 4px 6px 4px 12px; border: 1px solid #bfdbfe; border-radius: 999px; background: #eff6ff; color: #1e4ea8; overflow-wrap: anywhere; }
.crm .crm-chip > span { overflow-wrap: anywhere; }
.crm .crm-chip .crm-btn { flex-shrink: 0; min-width: 28px; min-height: 28px; padding: 2px 6px; border-radius: 999px; border-color: transparent; color: #1e4ea8; background: transparent; }
.crm .crm-chip .crm-btn:hover:not(:disabled) { background: #dbeafe; border-color: transparent; }
.crm .crm-skeleton { width: 100%; min-height: 160px; padding: 12px 0; }
.crm .crm-skeleton > div { height: 16px; width: 100%; margin-bottom: 16px; border-radius: 6px; background: #e5e7eb; animation: crm-loading-pulse 1.4s ease-in-out infinite; }
.crm .crm-skeleton > div:first-child { height: 24px; width: 36%; }
.crm .crm-skeleton > div:nth-child(3) { width: 78%; }
.crm .crm-skeleton > span { display: block; margin-top: 20px; }
.crm .crm-loading { min-height: 200px; }
.crm [aria-busy="true"] { cursor: progress; }
@keyframes crm-loading-pulse { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }

@media (max-width: 767px) {
  .crm .crm-card { padding: 16px; }
  .crm .crm-nav .settings-folder-tab { min-width: 130px; flex-basis: 130px; }
  .crm th, .crm td { padding-left: 16px; padding-right: 16px; }
  .crm .crm-filters label { max-width: none; }
  .crm .crm-filter-main > .crm-filter-search { max-width: none; }
}
@media (max-width: 639px) {
  .crm .crm-form-grid { grid-template-columns: minmax(0, 1fr); }
  .crm .crm-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .crm .crm-grid > .crm-card { padding: 14px; }
  .crm .crm-stat { font-size: 26px; }
  .crm .crm-nav { gap: 8px; }
  .crm .crm-nav .settings-folder-tab { min-width: 0; flex: 1 1 calc(50% - 8px); max-width: none; min-height: 54px; }
  .crm .crm-nav .order-tab-folder-label { font-size: 14px; }
  .crm .crm-filters { gap: 10px; }
  .crm .crm-filters label { flex-basis: calc(50% - 10px); }
  .crm .crm-filters label:has(input[name="q"]) { flex-basis: 100%; }
  .crm .crm-filter-main > label { flex-basis: calc(50% - 10px); }
  .crm .crm-filter-main > .crm-filter-search { flex-basis: 100%; }
  .crm .crm-filters-compact .crm-filter-details { flex-basis: auto; }
  .crm .crm-filters-compact .crm-filter-details[open] { flex-basis: 100%; }
  .crm .crm-table-summary, .crm .crm-pagination { width: 100%; justify-content: flex-start; }
  .crm .crm-pagination { gap: 6px; }
  .crm .crm-pagination .crm-btn { min-width: 34px; padding-inline: 10px; }
  .crm .crm-pipeline { grid-template-columns: repeat(4, minmax(245px, 82vw)); }
  dialog.crm { width: calc(100vw - 24px); max-height: calc(100dvh - 24px); padding: 16px; }
  dialog.crm .crm-dialog-header,
  dialog.crm .crm-modal-header { margin: -16px -16px 16px; padding: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .crm .crm-skeleton > div { animation: none; }
  .crm .crm-btn { transition: none; }
}

/* Lead profiles live inside the CRM folder panel. */
.crm .crm-lead-profile { display: grid; grid-template-columns: minmax(190px, .8fr) minmax(0, 2.5fr) minmax(230px, 1fr); gap: 16px; align-items: start; background: #f3f5f9; padding: 12px; border-radius: 12px; }
.crm .crm-profile-panel { min-width: 0; background: #fff; border: 1px solid #e5e7eb; border-radius: 12px; padding: 20px; }
.crm .crm-profile-summary h2 { overflow-wrap: anywhere; margin-top: 12px; }
.crm .crm-company-avatar { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: #eff6ff; color: #1e4ea8; font-size: 22px; font-weight: 700; margin: 24px 0 16px; }
.crm .crm-profile-actions { display: flex; flex-wrap: wrap; gap: 8px; border-top: 1px solid #e5e7eb; padding-top: 16px; }
.crm .crm-lead-stages { display: flex; overflow-x: auto; gap: 3px; padding-bottom: 12px; }
.crm .crm-lead-stage { flex: 1 0 100px; border: 0; background: #e2e8f0; color: #475569; font: inherit; font-size: 12px; font-weight: 600; padding: 12px 16px; clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 0 100%, 10px 50%); cursor: pointer; }
.crm .crm-lead-stage:first-child { border-radius: 24px 0 0 24px; clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 0 100%); }
.crm .crm-lead-stage:last-child { border-radius: 0 24px 24px 0; }
.crm .crm-lead-stage.is-active { background: #2563eb; color: #fff; }
.crm .crm-lead-stage:disabled { cursor: default; }
.crm .crm-lead-stage:hover:not(:disabled), .crm .crm-lead-stage:focus-visible { background: #1e40af; color: #fff; }
.crm .crm-profile-section > h3 { background: #f3f5f9; border-radius: 6px; padding: 10px 12px; margin: 16px 0; }
.crm .crm-profile-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px 32px; margin: 20px 12px 28px; }
.crm .crm-profile-fields dt { color: #64748b; font-size: 12px; margin-bottom: 6px; }
.crm .crm-profile-fields dd { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; color: #1f2937; }
.crm .crm-profile-summary .crm-profile-fields { grid-template-columns: 1fr; margin-inline: 0; }
.crm .crm-profile-notes > h3:first-child { margin-top: 0; }
.crm .crm-profile-notes .crm-scroll { margin-top: 16px; }
.crm .crm-profile-notes th, .crm .crm-profile-notes td { padding: 10px; }
.crm .crm-badge[data-status="Unqualified"] { color: #991b1b; background: #fee2e2; }
.crm .crm-pipeline { grid-template-columns: repeat(5, minmax(240px, 1fr)); }
@media (max-width: 1200px) {
  .crm .crm-lead-profile { grid-template-columns: minmax(180px, 1fr) minmax(0, 3fr); }
  .crm .crm-profile-notes { grid-column: 1 / -1; }
}
@media (max-width: 767px) {
  .crm .crm-lead-profile { grid-template-columns: minmax(0, 1fr); padding: 0; }
  .crm .crm-profile-panel { padding: 16px; }
  .crm .crm-profile-fields { gap: 20px; margin-inline: 0; }
}
@media (max-width: 480px) {
  .crm .crm-profile-fields { grid-template-columns: minmax(0, 1fr); }
}

/* Preserved newer CRM feature/loading/profile styles. */
.crm .crm-nav-shell { position: relative; display: flex; align-items: flex-start; gap: 10px; min-width: 0; margin-bottom: 0; }

.crm .crm-nav-shell::after { content: ''; position: absolute; right: 0; bottom: 0; left: 0; height: 1px; background: #d9e3f0; }

.crm .crm-nav-shell .crm-nav { flex: 1 1 0; min-width: 0; flex-wrap: nowrap; overflow: hidden; margin-bottom: 0; max-width: 100%; }

.crm .crm-nav-actions { display: flex; flex: 0 0 auto; flex-wrap: nowrap; gap: 8px; justify-content: flex-end; margin-top: 12px; }

.crm .crm-see-more { position: relative; z-index: 2; flex: 0 0 auto; min-height: 44px; }

.crm .crm-nav-overflow-hidden { display: none !important; }

@media (max-width: 560px) {
  .crm .crm-nav-shell { flex-direction: column; gap: 0; }
  .crm .crm-nav-shell .crm-nav { width: 100%; flex: 0 0 auto; }
  .crm .crm-nav-actions { order: -1; justify-content: flex-start; margin: 0 0 12px; }
}

.crm .crm-category-bar { min-width: 0; margin: 16px 0 20px; }

.crm .crm-category-scroller { position: relative; min-width: 0; }

.crm .crm-category-tabs { display: flex; flex: 1 1 auto; flex-wrap: nowrap; gap: 8px; min-width: 0; overflow-x: auto; overflow-y: hidden; padding: 2px 28px 8px 2px; scrollbar-width: auto; scrollbar-color: #6f87b5 #e8eef8; overscroll-behavior-x: contain; }

.crm .crm-category-tabs::-webkit-scrollbar { height: 10px; }
.crm .crm-category-tabs::-webkit-scrollbar-track { border-radius: 999px; background: #e8eef8; }
.crm .crm-category-tabs::-webkit-scrollbar-thumb { min-width: 40px; border: 2px solid #e8eef8; border-radius: 999px; background-color: #6f87b5; background-image: radial-gradient(circle, rgb(255 255 255 / 85%) 1px, transparent 1.5px); background-size: 5px 5px; cursor: grab; }
.crm .crm-category-tabs::-webkit-scrollbar-thumb:active { cursor: grabbing; background-color: #1e4ea8; }

.crm .crm-category-tabs .crm-btn { flex: 0 0 auto; white-space: nowrap; }

.crm .crm-category-overflow-indicator { position: absolute; z-index: 1; top: 50%; right: 0; display: grid; width: 24px; height: 30px; place-items: center; transform: translateY(-60%); color: #1e4ea8; background: linear-gradient(90deg, transparent, #fff 38%); font-size: 23px; font-weight: 500; line-height: 1; pointer-events: none; }
.crm .crm-category-overflow-indicator.is-left { background: linear-gradient(270deg, transparent, #fff 38%); }

.crm .crm-section-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.crm .crm-section-heading h3 { margin-bottom: 0; }

/* Profile communication records are deliberately compact cards, not audit tables. */
.crm .crm-btn.compact { min-height: 28px; padding: 4px 8px; font-size: 12px; }
.crm .crm-note-list,
.crm .crm-interaction-list { display: grid; gap: 10px; margin-top: 12px; }
.crm .crm-note,
.crm .crm-interaction-card { margin: 0; padding: 12px; border: 1px solid #dbe3ef; border-radius: 10px; background: #f8fafc; box-shadow: 0 1px 2px rgb(15 23 42 / 4%); }
.crm .crm-note p,
.crm .crm-interaction-card p { margin: 8px 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.crm .crm-interaction-card-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 28px; }
.crm .crm-note .crm-interaction-card-header:empty { display: none; }
.crm .crm-system-activities [data-profile-activities] { margin-top: 12px; }
.crm .crm-system-activity-scroll { max-height: 505px; overflow: auto; overscroll-behavior: contain; border: 1px solid #e5e7eb; border-radius: 10px; }
.crm .crm-system-activity-scroll .crm-scroll { overflow: visible; }
.crm .crm-system-activity-scroll table { min-width: 580px; }

.crm .crm-lane > h3 .crm-lead-stage { flex: 1 1 auto; cursor: default; }

.crm .crm-note-list { display: grid; gap: 10px; }

.crm .crm-note { padding: 12px; border: 1px solid #e5e7eb; border-radius: 10px; background: #f9fafb; }

.crm .crm-note p { margin: 0 0 8px; white-space: pre-wrap; }

.crm .crm-loading-host { position: relative; }

.crm .crm-delayed-loading {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(248, 250, 252, .72);
  pointer-events: none;
}

.crm #crm-content > .crm-delayed-loading {
  position: fixed;
  inset: 0;
  z-index: 70;
}

dialog.crm > .crm-delayed-loading,
dialog.crm .crm-modal-body > .crm-delayed-loading {
  position: absolute;
  inset: 0;
}

.crm .crm-loading-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-width: 180px;
  padding: 22px 26px;
  border: 1px solid #bfdbfe;
  border-radius: 12px;
  background: rgba(255,255,255,.96);
  box-shadow: 0 18px 42px rgba(15,23,42,.12);
  color: #1e3a8a;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}

.crm .crm-loading-spinner {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 3px solid #bfdbfe;
  border-top-color: #2563eb;
  animation: crm-loading-spin .75s linear infinite;
}

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

.crm .crm-profile-header { grid-column: 1 / -1; min-width: 0; padding: 8px 8px 0; }

.crm .crm-profile-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 24px; }

.crm .crm-profile-toolbar > .crm-btn:last-child { margin-left: auto; }

.crm .crm-profile-status-heading { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; font-size: 13px; }

.crm .crm-profile-subtitle { overflow-wrap: anywhere; margin: 8px 0 16px; }

.crm .crm-profile-summary .crm-profile-actions > .crm-btn { flex: 1 1 100%; }

.crm .crm-profile-main > .crm-profile-section:first-child > h3 { margin-top: 0; }

.crm .crm-lead-stage.is-active[data-status="New"] { background: #2563eb; }

.crm .crm-lead-stage.is-active[data-status="Contacted"] { background: #0e7490; }

.crm .crm-lead-stage.is-active[data-status="Nurturing"] { background: #7e22ce; }

.crm .crm-lead-stage.is-active[data-status="Converted"] { background: #15803d; }

.crm .crm-lead-stage.is-active[data-status="Unqualified"] { background: #b91c1c; }

.crm .crm-activity-type, .crm [data-activity-type] { background: #f1f5f9; color: #334155; }

.crm .crm-activity-type { display: inline-block; padding: 5px 10px; border-radius: 6px; font-weight: 600; white-space: nowrap; }

.crm [data-type="Call"] { background: #dbeafe; color: #1e40af; }

.crm [data-type="Email"] { background: #cffafe; color: #155e75; }

.crm [data-type="Messenger"] { background: #ede9fe; color: #5b21b6; }

.crm [data-type="Meeting"] { background: #dcfce7; color: #166534; }

.crm [data-type="Quotation Sent"] { background: #fef3c7; color: #92400e; }

.crm [data-type="Proposal Sent"] { background: #fce7f3; color: #9d174d; }

.crm [data-type="Follow-up"] { background: #ffedd5; color: #9a3412; }

.crm [data-type="Note"] { background: #e2e8f0; color: #334155; }

dialog.crm.crm-profile-dialog { width: min(1400px, calc(100vw - 24px)); }

.crm [data-profile-section][hidden] { display: none; }

.crm .crm-nav .settings-folder-tab { flex: 0 0 150px; min-width: 150px; max-width: 150px; }
@media (max-width: 767px) { .crm .crm-nav .settings-folder-tab { flex-basis: 130px; min-width: 130px; max-width: 130px; } }
