/* Portal page and section headings share one spacing and alignment contract. */
:where(.ds-root) .cp-main .cp-page-head {
  align-items: flex-start;
  gap: var(--ds-space-4);
}

:where(.ds-root) .cp-main .cp-page-head .ds-page-heading {
  gap: var(--ds-space-1);
  min-width: 0;
}

:where(.ds-root) .cp-main .cp-page-head .cp-eyebrow,
:where(.ds-root) .cp-main .cp-page-head :is(h1, p) {
  margin: 0;
}

:where(.ds-root) .cp-main .cp-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--ds-space-3);
  min-width: 0;
  margin: 0 0 var(--ds-space-4);
  padding: 0 0 var(--ds-space-4);
  border-bottom: 1px solid var(--ds-border);
}

:where(.ds-root) .cp-main .cp-section-head__copy {
  display: grid;
  gap: var(--ds-space-1);
  flex: 1 1 240px;
  min-width: 0;
}

:where(.ds-root) .cp-main .cp-section-head :is(h2, h3, p, ul) {
  margin: 0;
  overflow-wrap: anywhere;
}

:where(.ds-root) .cp-main .cp-section-head .ds-h3 {
  font-size: 18px;
  line-height: 1.4;
}

:where(.ds-root) .cp-main .cp-section-head .ds-hint {
  line-height: 1.5;
}

:where(.ds-root) .cp-main .cp-section-head > :is(.ds-badge, a, button, form) {
  flex: 0 0 auto;
}

:where(.ds-root) .cp-main .cp-section-head > .ds-badge {
  margin-top: 2px;
}

/* Stack-only headers contain explanatory lists or shared consultation copy. */
:where(.ds-root) .cp-main .cp-section-head--guide,
:where(.ds-root) .cp-main .cp-section-head--stack {
  display: grid;
  gap: var(--ds-space-1);
}

:where(.ds-root) .cp-main .cp-section-head--guide ul {
  padding-left: 18px;
  display: grid;
  gap: var(--ds-space-1);
}

/* Grid cards already provide the gap after the header. */
:where(.ds-root) .cp-main .ds-card.cp-progress,
:where(.ds-root) .cp-main .ds-settings-card:has(> .cp-section-head) {
  gap: var(--ds-space-4);
}

:where(.ds-root) .cp-main :is(.cp-progress, .ds-settings-card) > .cp-section-head {
  margin-bottom: 0;
}

@media (max-width: 640px) {
  :where(.ds-root) .cp-main .cp-section-head__copy {
    flex-basis: 180px;
  }

  :where(.ds-root) .cp-main .cp-section-head .ds-h3 {
    font-size: 16px;
  }
}

/* Optional filters sit beside the title, then span the header on narrow screens. */
:where(.ds-root) .cp-main .cp-section-head__filter {
  width: 280px;
  max-width: 100%;
  flex: 0 0 auto;
}

@media (max-width: 640px) {
  :where(.ds-root) .cp-main .cp-section-head__filter {
    width: 100%;
  }
}

/* Dashboard snapshot time belongs to the greeting card in every workspace. */
:where(.ds-root) .cp-dashboard-updated {
  margin: 8px 0 0;
  color: var(--ds-text-secondary);
  font-size: var(--ds-text-xs);
  font-variant-numeric: tabular-nums;
  line-height: 1.6;
}
:where(.ds-root) :is(.cp-company-welcome, .cp-dashboard-profile) .cp-dashboard-updated {
  color: rgba(255, 255, 255, 0.8);
}

:where(.ds-root) :is(.cp-dashboard-greeting-title, .cp-greeting-copy) > .cp-dashboard-updated {
  margin-top: 4px;
  font-size: var(--ds-text-xs);
  font-weight: normal;
}
